List of usage examples for android.os Build MODEL
String MODEL
To view the source code for android.os Build MODEL.
Click Source Link
From source file:com.example.feedback.ActivityMain.java
/** * Get device information and save to application cache to send as attachment in feedback email. *///from www . j a v a 2 s .co m public void getDeviceInfo() { try { dateTime = new Date(); timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US); packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); appName = getApplicationContext().getString(packageInfo.applicationInfo.labelRes); appVersion = packageInfo.versionName; appCode = Integer.toString(packageInfo.versionCode); // Get application information. stringInfo = "date/time: " + timeFormat.format(dateTime) + "\n\n"; stringInfo += "packageName: " + packageInfo.packageName + "\n"; stringInfo += "packageCode: " + appCode + "\n"; stringInfo += "packageVersion: " + appVersion + "\n"; // Get network information. telephonyManager = ((TelephonyManager) getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE)); if (!telephonyManager.getNetworkOperatorName().equals("")) { stringInfo += "operatorNetName: " + telephonyManager.getNetworkOperatorName() + "\n"; } else if (!telephonyManager.getSimOperatorName().equals("")) { stringInfo += "operatorSimName: " + telephonyManager.getSimOperatorName() + "\n"; } // Get device information. stringInfo += "Build.MODEL: " + Build.MODEL + "\n"; stringInfo += "Build.BRAND: " + Build.BRAND + "\n"; stringInfo += "Build.DEVICE: " + Build.DEVICE + "\n"; stringInfo += "Build.PRODUCT: " + Build.PRODUCT + "\n"; stringInfo += "Build.ID: " + Build.ID + "\n"; stringInfo += "Build.TYPE: " + Build.TYPE + "\n"; stringInfo += "Build.VERSION.SDK_INT: " + Build.VERSION.SDK_INT + "\n"; stringInfo += "Build.VERSION.RELEASE: " + Build.VERSION.RELEASE + "\n"; stringInfo += "Build.VERSION.INCREMENTAL: " + Build.VERSION.INCREMENTAL + "\n"; stringInfo += "Build.VERSION.CODENAME: " + Build.VERSION.CODENAME + "\n"; stringInfo += "Build.BOARD: " + Build.BOARD + "\n\n"; // Get other application information. activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); runningProcesses = activityManager.getRunningAppProcesses(); runningApplications = ""; for (ActivityManager.RunningAppProcessInfo runningProcess : runningProcesses) { runningApplications += "\n " + runningProcess.processName; } stringInfo += "Applications running:" + runningApplications; // Save information to cached file. fileOutput = new FileOutputStream(getCacheDir().getAbsolutePath() + "/deviceInfo.log"); fileOutput.write(stringInfo.getBytes()); fileOutput.close(); } catch (Exception e) { } }
From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_layout); // Create the adapter that will return a fragment for each of the three primary sections of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*w w w .j a v a 2s .c o m*/ public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE); ; SharedPreferences.Editor editor = settings.edit(); // load the default parameters into SharedPreferences for the first time launch int ct = settings.getInt("count", 0); if (ct == 0) { editor.putString("start", "9"); editor.putString("end", "21"); editor.putString("interval", "15"); editor.putString("duration", "5"); editor.putString("location", "On"); editor.putString("upload", "On"); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); editor.putString("IMEI", tm.getDeviceId()); editor.putString("brand", Build.BRAND); editor.putString("model", Build.MODEL); String phone_type = Build.BRAND + "_" + Build.MODEL; // motoX if (phone_type.equals("motorola_XT1058")) { editor.putString("mfcc_dist_same_semi", "13"); editor.putString("mfcc_dist_diff_semi", "18"); editor.putString("mfcc_dist_same_un", "13"); editor.putString("mfcc_dist_diff_un", "18"); } // nexus 4 else if (phone_type.equals("google_Nexus 4")) { editor.putString("mfcc_dist_same_semi", "17"); editor.putString("mfcc_dist_diff_semi", "22"); editor.putString("mfcc_dist_same_un", "17"); editor.putString("mfcc_dist_diff_un", "22"); } // s2 else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) { editor.putString("mfcc_dist_same_semi", "18"); editor.putString("mfcc_dist_diff_semi", "25"); editor.putString("mfcc_dist_same_un", "18"); editor.putString("mfcc_dist_diff_un", "25"); } // s3 else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) { editor.putString("mfcc_dist_same_semi", "16"); editor.putString("mfcc_dist_diff_semi", "21"); editor.putString("mfcc_dist_same_un", "16"); editor.putString("mfcc_dist_diff_un", "21"); } // s4 else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) { editor.putString("mfcc_dist_same_semi", "14"); editor.putString("mfcc_dist_diff_semi", "24"); editor.putString("mfcc_dist_same_un", "14"); editor.putString("mfcc_dist_diff_un", "24"); } // other devices else { editor.putString("mfcc_dist_same_semi", "15.6"); editor.putString("mfcc_dist_diff_semi", "21.6"); editor.putString("mfcc_dist_same_un", "15.6"); editor.putString("mfcc_dist_diff_un", "21.6"); Toast.makeText(this, "Your device is not recognized and the result might not be accurate...", Toast.LENGTH_SHORT).show(); } Log.i("Crowd++", "First time launched"); AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("Welcome to Crowd++"); dialog.setMessage(Constants.hello_msg); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); } editor.putInt("count", ++ct); editor.commit(); Log.i("Launched Count", Integer.toString(ct)); mConst = new Constants(this); if (!Constants.calibration()) Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show(); }
From source file:org.artoolkit.ar.unity.UnityARPlayerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // For Epson Moverio BT-200. if (Build.MANUFACTURER.equals("EPSON") && Build.MODEL.equals("embt2")) { mDisplayControl = new DisplayControl(this); //private static final int FLAG_SMARTFULLSCREEN = 0x80000000; // For Epson Moverio BT-200. getWindow().addFlags(0x80000000); }// w w w .j a v a 2s . c o m super.onCreate(savedInstanceState); // This needs to be done just only the very first time the application is run, // or whenever a new preference is added (e.g. after an application upgrade). int resID = getResources().getIdentifier("preferences", "xml", getPackageName()); PreferenceManager.setDefaultValues(this, resID, false); //Request permission to use the camera on android 23+ int permissionCheck = ContextCompat.checkSelfPermission(this.getApplicationContext(), Manifest.permission.CAMERA); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, PERMISSION_REQUEST_CAMERA); } }
From source file:com.google.android.apps.location.gps.gnsslogger.FileLogger.java
/** * Start a new file logging process./*w w w. j a v a 2s . c o m*/ */ public void startNewLog() { synchronized (mFileLock) { File baseDirectory; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { baseDirectory = new File(Environment.getExternalStorageDirectory(), FILE_PREFIX); baseDirectory.mkdirs(); } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { logError("Cannot write to external storage."); return; } else { logError("Cannot read external storage."); return; } SimpleDateFormat formatter = new SimpleDateFormat("yyy_MM_dd_HH_mm_ss"); Date now = new Date(); String fileName = String.format("%s_%s.txt", FILE_PREFIX, formatter.format(now)); File currentFile = new File(baseDirectory, fileName); String currentFilePath = currentFile.getAbsolutePath(); BufferedWriter currentFileWriter; try { currentFileWriter = new BufferedWriter(new FileWriter(currentFile)); } catch (IOException e) { logException("Could not open file: " + currentFilePath, e); return; } // initialize the contents of the file try { currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.write("Header Description:"); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.write(VERSION_TAG); String manufacturer = Build.MANUFACTURER; String model = Build.MODEL; String fileVersion = mContext.getString(R.string.app_version) + " Platform: " + Build.VERSION.RELEASE + " " + "Manufacturer: " + manufacturer + " " + "Model: " + model; currentFileWriter.write(fileVersion); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter .write("Raw,ElapsedRealtimeMillis,TimeNanos,LeapSecond,TimeUncertaintyNanos,FullBiasNanos," + "BiasNanos,BiasUncertaintyNanos,DriftNanosPerSecond,DriftUncertaintyNanosPerSecond," + "HardwareClockDiscontinuityCount,Svid,TimeOffsetNanos,State,ReceivedSvTimeNanos," + "ReceivedSvTimeUncertaintyNanos,Cn0DbHz,PseudorangeRateMetersPerSecond," + "PseudorangeRateUncertaintyMetersPerSecond," + "AccumulatedDeltaRangeState,AccumulatedDeltaRangeMeters," + "AccumulatedDeltaRangeUncertaintyMeters,CarrierFrequencyHz,CarrierCycles," + "CarrierPhase,CarrierPhaseUncertainty,MultipathIndicator,SnrInDb," + "ConstellationType,AgcDb,CarrierFrequencyHz"); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.write("Fix,Provider,Latitude,Longitude,Altitude,Speed,Accuracy,(UTC)TimeInMs"); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.write("Nav,Svid,Type,Status,MessageId,Sub-messageId,Data(Bytes)"); currentFileWriter.newLine(); currentFileWriter.write(COMMENT_START); currentFileWriter.newLine(); } catch (IOException e) { logException("Count not initialize file: " + currentFilePath, e); return; } if (mFileWriter != null) { try { mFileWriter.close(); } catch (IOException e) { logException("Unable to close all file streams.", e); return; } } mFile = currentFile; mFileWriter = currentFileWriter; Toast.makeText(mContext, "File opened: " + currentFilePath, Toast.LENGTH_SHORT).show(); // To make sure that files do not fill up the external storage: // - Remove all empty files FileFilter filter = new FileToDeleteFilter(mFile); for (File existingFile : baseDirectory.listFiles(filter)) { existingFile.delete(); } // - Trim the number of files with data File[] existingFiles = baseDirectory.listFiles(); int filesToDeleteCount = existingFiles.length - MAX_FILES_STORED; if (filesToDeleteCount > 0) { Arrays.sort(existingFiles); for (int i = 0; i < filesToDeleteCount; ++i) { existingFiles[i].delete(); } } } }
From source file:com.dunrite.xpaper.utility.Utils.java
/** * Gets device name and returns string for the intro activity * * @return finished sentence saying the recognized device *///from ww w. j ava 2 s .c o m public static String getDeviceNameString(Activity a) { String name = Build.MODEL; String s = "It looks like you have a "; String model; //String to provide color fragment //getting arrays of each model and it's associated model numbers String[] pure = a.getResources().getStringArray(R.array.pure_model_number_array); String[] style = a.getResources().getStringArray(R.array.style_model_number_array); String[] play = a.getResources().getStringArray(R.array.play_model_number_array); String[] force = a.getResources().getStringArray(R.array.force_model_number_array); String[] x13 = a.getResources().getStringArray(R.array.x13_model_number_array); String[] x14 = a.getResources().getStringArray(R.array.x14_model_number_array); Log.d("Model Number", name); if (Arrays.asList(pure).contains(name)) { model = "PURE"; s = s.concat("Moto X Pure Edition"); } else if (Arrays.asList(style).contains(name)) { model = "STYLE"; s = s.concat("Moto X Style"); } else if (Arrays.asList(play).contains(name)) { model = "PLAY"; s = s.concat("Moto X Play"); } else if (Arrays.asList(force).contains(name)) { model = "FORCE"; s = s.concat("Moto X Force"); } else if (Arrays.asList(x13).contains(name)) { model = "2013"; s = s.concat("Moto X 2013"); } else if (Arrays.asList(x14).contains(name)) { model = "2014"; s = s.concat("Moto X 2014"); } else { model = "PURE"; s = "It looks like you don't have a Moto X. That is OK"; } saveDeviceConfig(a, stringToModel(model), "model", "MODEL"); s = s.concat(".\nContinue to configure your colors.\n\n"); Log.d("Device Name", model); return s; }
From source file:com.hijacker.SendLogActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setFinishOnTouchOutside(false);/*from w w w .j ava 2s . c o m*/ setContentView(R.layout.activity_send_log); rootView = findViewById(R.id.activity_send_log); userEmailView = (EditText) findViewById(R.id.email_et); extraView = (EditText) findViewById(R.id.extra_et); progressBar = findViewById(R.id.reportProgressBar); console = (TextView) findViewById(R.id.console); sendProgress = findViewById(R.id.progress); sendCompleted = findViewById(R.id.completed); sendBtn = findViewById(R.id.sendBtn); sendEmailBtn = findViewById(R.id.sendEmailBtn); userEmailView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { extraView.requestFocus(); return true; } return false; } }); busybox = getFilesDir().getAbsolutePath() + "/bin/busybox"; stackTrace = getIntent().getStringExtra("exception"); Log.e("HIJACKER/SendLog", stackTrace); pref = PreferenceManager.getDefaultSharedPreferences(SendLogActivity.this); pref_edit = pref.edit(); userEmailView.setText(pref.getString("user_email", "")); //Load device info PackageManager manager = getPackageManager(); PackageInfo info; try { info = manager.getPackageInfo(getPackageName(), 0); versionName = info.versionName.replace(" ", "_"); versionCode = info.versionCode; } catch (PackageManager.NameNotFoundException e) { Log.e("HIJACKER/SendLog", e.toString()); } deviceModel = Build.MODEL; if (!deviceModel.startsWith(Build.MANUFACTURER)) deviceModel = Build.MANUFACTURER + " " + deviceModel; deviceModel = deviceModel.replace(" ", "_"); deviceID = pref.getLong("deviceID", -1); new SetupTask().execute(); }
From source file:org.cook_e.cook_e.BugReportActivity.java
/** * Gathers information about the device running the application and returns it as a JSONObject * @return information about the system//from w w w . j a v a 2 s . c om */ private JSONObject getSystemInformation() { final JSONObject json = new JSONObject(); try { final JSONObject build = new JSONObject(); build.put("version_name", BuildConfig.VERSION_NAME); build.put("version_code", BuildConfig.VERSION_CODE); build.put("build_type", BuildConfig.BUILD_TYPE); build.put("debug", BuildConfig.DEBUG); json.put("build", build); final JSONObject device = new JSONObject(); device.put("board", Build.BOARD); device.put("bootloader", Build.BOOTLOADER); device.put("brand", Build.BRAND); device.put("device", Build.DEVICE); device.put("display", Build.DISPLAY); device.put("fingerprint", Build.FINGERPRINT); device.put("hardware", Build.HARDWARE); device.put("host", Build.HOST); device.put("id", Build.ID); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); device.put("product", Build.PRODUCT); device.put("radio", Build.getRadioVersion()); device.put("serial", Build.SERIAL); device.put("tags", Build.TAGS); device.put("time", Build.TIME); device.put("type", Build.TYPE); device.put("user", Build.USER); json.put("device", device); } catch (JSONException e) { // Ignore } return json; }
From source file:org.adblockplus.android.AdblockPlus.java
/** * Returns device name in user-friendly format *///from w w w . j a va 2 s . c o m public static String getDeviceName() { String manufacturer = Build.MANUFACTURER; String model = Build.MODEL; if (model.startsWith(manufacturer)) return capitalize(model); else return capitalize(manufacturer) + " " + model; }
From source file:com.mobicage.rogerthat.util.logging.L.java
private static void logToServer(final String s, final Throwable t) { try {//from w ww . j av a 2s . c om if (sMainService == null) return; final long currentTimeMillis = sMainService.currentTimeMillis(); if (currentTimeMillis - sLastErrorLogTimestamp < MAX_SEND_RATE) return; sLastErrorLogTimestamp = currentTimeMillis; try { throw new Exception(); } catch (final Exception e) { if (sMainService.getRegisteredFromConfig()) { sMainService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { if (sMainService == null) return; LogErrorRequestTO request = new LogErrorRequestTO(); request.description = s; request.platform = 1; request.timestamp = currentTimeMillis / 1000; request.mobicageVersion = (sMainService.isDebug() ? "-" : "") + sMainService.getMajorVersion() + "." + sMainService.getMinorVersion(); request.platformVersion = Build.FINGERPRINT + " (-) " + SystemUtils.getAndroidVersion() + " (-) " + Build.MODEL; setErrorMessageOnLogErrorRequest(t == null ? e : t, request); Rpc.logError(new ResponseHandler<LogErrorResponseTO>(), request); } }); } else { new AsyncTask<Object, Object, Object>() { @Override protected Object doInBackground(Object... params) { if (sMainService == null) return null; try { HttpPost httpPostRequest = new HttpPost(CloudConstants.LOG_ERROR_URL); httpPostRequest.setHeader("Content-Type", "application/x-www-form-urlencoded"); RegistrationWizard2 wiz = RegistrationWizard2.getWizard(sMainService); List<NameValuePair> formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("install_id", wiz.getInstallationId())); formParams.add(new BasicNameValuePair("device_id", wiz.getDeviceId())); formParams .add(new BasicNameValuePair("language", Locale.getDefault().getLanguage())); formParams.add(new BasicNameValuePair("country", Locale.getDefault().getCountry())); formParams.add(new BasicNameValuePair("description", s)); formParams.add(new BasicNameValuePair("platform", "1")); formParams.add(new BasicNameValuePair("platform_version", "" + SystemUtils.getAndroidVersion())); formParams.add(new BasicNameValuePair("timestamp", "" + System.currentTimeMillis() / 1000)); formParams.add(new BasicNameValuePair("mobicage_version", MainService.getVersion(sMainService))); formParams.add(new BasicNameValuePair("error_message", getStackTraceString(t == null ? e : t))); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, HTTP.UTF_8); httpPostRequest.setEntity(entity); HTTPUtil.getHttpClient().execute(httpPostRequest); } catch (Exception e1) { L.d("Error while posting error to server", e1); } return null; } }.execute(); } } } catch (Exception e) { L.d("Error while posting error to server", e); } }
From source file:com.yojiokisoft.japanesecalc.MyUncaughtExceptionHandler.java
/** * ?????./*from ww w.ja v a 2 s . c om*/ */ private static void postBugReport() { List<NameValuePair> nvps = new ArrayList<NameValuePair>(); String bug = getFileBody(sBugReportFile); nvps.add(new BasicNameValuePair("dev", Build.DEVICE)); nvps.add(new BasicNameValuePair("mod", Build.MODEL)); nvps.add(new BasicNameValuePair("sdk", String.valueOf(Build.VERSION.SDK_INT))); nvps.add(new BasicNameValuePair("ver", sVersionName)); nvps.add(new BasicNameValuePair("bug", bug)); try { HttpPost httpPost = new HttpPost("http://mrp-bug-report.appspot.com/bug"); httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.execute(httpPost); } catch (IOException e) { e.printStackTrace(); } sBugReportFile.delete(); }