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.tencent.wetest.common.util.DeviceUtil.java
/** * ??//from ww w . java 2 s . co m * @param context * @return DeviceInfoJSON? */ public static String getDeviceInfo(Context context) { try { JSONArray content_f_Device = new JSONArray(); JSONObject manu = new JSONObject(); manu.put("manu", android.os.Build.BRAND); content_f_Device.put(manu); JSONObject model = new JSONObject(); model.put("model", android.os.Build.MODEL); content_f_Device.put(model); JSONObject version = new JSONObject(); version.put("version", getVersion(context)); content_f_Device.put(version); JSONObject cpu = new JSONObject(); cpu.put("cpu", "" + getCpuCoreNum()); content_f_Device.put(cpu); JSONObject mem = new JSONObject(); mem.put("mem", "" + getTotalMemory(context)); content_f_Device.put(mem); JSONObject resolution = new JSONObject(); resolution.put("resolution", "" + getDisplayMetrics(context)); content_f_Device.put(resolution); JSONObject cpufreq = new JSONObject(); cpufreq.put("cpufreq", getCpuMaxFreq()); content_f_Device.put(cpufreq); //+","+getCpuMinFreq() JSONObject cpuname = new JSONObject(); cpuname.put("cpuname", getCpuName()); content_f_Device.put(cpuname); return content_f_Device.toString(); } catch (JSONException e) { Logger.error("getDeviceInfo Exception : " + e.toString()); } return null; }
From source file:com.euphor.paperpad.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId /*from www .ja v a 2s . com*/ */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = MainActivity.params.getId(); String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; if (MainActivity.isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, MainActivity.prod_or_sand, "sales", application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, hits); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:io.kristal.appinfos.AppInfosPlugin.java
private synchronized static String getUniqueId(Context context) { String uniqueID = null;/*from w w w.j a va 2s.c o m*/ SharedPreferences sharedPrefs = context.getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE); uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null); if (uniqueID == null) { uniqueID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); if (uniqueID == null || uniqueID.length() == 0 || "9774d56d682e549c".equals(uniqueID)) { // old version of reto meier //uniqueID = UUID.randomUUID().toString(); uniqueID = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits } SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putString(PREF_UNIQUE_ID, uniqueID); editor.commit(); } return uniqueID; }
From source file:bg.phpgcm2.RegistrationIntentService.java
/** * Persist registration to third-party servers. * * Modify this method to associate the user's GCM registration token with any server-side account * maintained by your application./*from ww w. j a v a 2 s . co m*/ * * @param token The new token. */ private void sendRegistrationToServer(String token) { // TODO: Implement this method to send any registration to your app's servers. Log.i(TAG, "registering device (token = " + token + ")"); String serverUrl = "https://www.smclinic.bg/conn/authorize.php"; Map<String, String> params = new HashMap<String, String>(); TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String deviceid = tm.getDeviceId(); String manufacturer = Build.MANUFACTURER; String model = Build.MODEL; ; if (!(model.startsWith(manufacturer))) { model = manufacturer + " " + model; } String serialno = Build.SERIAL; String osversion = Build.VERSION.RELEASE; SharedPreferences spsettings = getSharedPreferences("Motolife", MODE_PRIVATE); SharedPreferences.Editor speditor = spsettings.edit(); params.put("fb", deviceid); speditor.putString("fb", deviceid); params.put("token", token); speditor.putString("token", token); params.put("fbname", "FB_name"); speditor.putString("fbname", "FB_name"); params.put("fbemail", "FB email"); speditor.putString("fbemail", "FB_email"); params.put("name", "name"); speditor.putString("name", "name"); params.put("email", "email"); speditor.putString("email", "email"); params.put("phone", ""); speditor.putString("phone", ""); params.put("bdate", "19770425"); speditor.putString("bdate", "19770425"); params.put("imei", deviceid); speditor.putString("imei", deviceid); params.put("serial", serialno); speditor.putString("serial", serialno); params.put("model", model); speditor.putString("model", model); params.put("osversion", osversion); speditor.putString("osversion", osversion); params.put("meters", "25"); speditor.putString("meters", "25"); params.put("xcoord", "0.123456"); speditor.putString("xcoord", Double.toString(0.123456)); params.put("ycoord", "0.123456"); speditor.putString("ycoord", Double.toString(0.123456)); params.put("version", "0.1"); speditor.putString("version", "0.1"); params.put("in", "0"); speditor.putString("in", "0"); params.put("platform", "0"); params.put("sh", "0"); speditor.putString("sh", "0"); speditor.commit(); try { post(serverUrl, params); } catch (IOException e) { Log.e(TAG, "Failed to register on attempt " + e); } Log.i(TAG, "registered"); }
From source file:com.amazonaws.mobileconnectors.util.ClientContext.java
/** * Gets the device info, including platform, model, make, platform_version, * and locale.// w w w .jav a 2 s . c o m * * @param context context of the app * @return an JSONObject that has the device info * @throws JSONException */ static JSONObject getDeviceInfo(Context context) throws JSONException { final JSONObject env = new JSONObject().put("platform", "Android").put("model", Build.MODEL) .put("make", Build.MANUFACTURER).put("platform_version", Build.VERSION.RELEASE) .put("locale", Locale.getDefault().toString()); return env; }
From source file:com.yojiokisoft.globish1500.exception.MyUncaughtExceptionHandler.java
/** * ?????./* w ww . j a v a 2 s . c o m*/ */ 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", Build.VERSION.SDK)); 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(); }
From source file:com.error.hunter.ListenService.java
private void generateBugReport(ActivityManager.ProcessErrorStateInfo entry) { String condition;/*w w w . jav a2s .co m*/ badProcess = entry.processName; String build = Build.DISPLAY; String fingerprint = Build.FINGERPRINT; String serial = Build.SERIAL; String product = Build.PRODUCT; String model = Build.MODEL; File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); @SuppressWarnings("deprecation") long blockSize = stat.getBlockSize(); @SuppressWarnings("deprecation") long availableBlocks = stat.getAvailableBlocks(); String memory = Formatter.formatFileSize(this, availableBlocks * blockSize).toString(); MemoryInfo mi = new MemoryInfo(); ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); long availableMegs = mi.availMem / 1048576L; strBuf.append("Problem detected in: ").append(badProcess); if (entry.tag != null) { strBuf.append(" (").append(entry.tag).append(")"); } strBuf.append("\nDevice product: " + product); strBuf.append("\nDevice model: " + model); strBuf.append("\nDevice build: " + build); strBuf.append("\nDevice fingerprint: " + fingerprint); strBuf.append("\nDevice SN: " + serial); strBuf.append("\nDevice available RAM (MB): " + availableMegs); strBuf.append("\nDevice free phisical memory: " + memory + "\n"); strBuf.append(getNetworkInfo()); strBuf.append("\n"); ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> procInfos = actvityManager.getRunningServices(1000); Iterator<RunningServiceInfo> taskIter = procInfos.iterator(); RunningServiceInfo info; while (taskIter.hasNext()) { info = taskIter.next(); if (info.process.equals(badProcess)) { strBuf.append("\nService " + info.service + " crash count: " + info.crashCount + " active since: " + info.activeSince + " process: " + info.process); } } strBuf.append("\n"); //android.os.Debug.MemoryInfo[] miPid = activityManager.getProcessMemoryInfo(new int[]{entry.pid}); //String memoryProc = miPid[0].toString(); //strBuf.append("\nRAM used by process (Process: " + entry.processName + " PID: " + entry.pid +"): " + memoryProc + "MB\n"); switch (entry.condition) { case ActivityManager.ProcessErrorStateInfo.CRASHED: condition = "CRASHED"; getDeviceProcessInfo(badProcess, entry.stackTrace); writeLogsToFile(condition, badProcess); break; case ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING: condition = "ANR"; getDeviceProcessInfo(badProcess, ""); writeLogsToFile(condition, badProcess); break; default: condition = "<unknown>"; getDeviceProcessInfo(badProcess, entry.stackTrace); writeLogsToFile(condition, badProcess); break; } }
From source file:de.akquinet.android.androlog.reporter.Report.java
/** * Adds the device data to the report.//from w w w . j a va 2 s. c o m * @param context * @throws JSONException if the device data cannot be added */ private void buildDeviceData(Context context) throws JSONException { device = new JSONObject(); device.put("device", Build.DEVICE); device.put("brand", Build.BRAND); Object windowService = context.getSystemService(Context.WINDOW_SERVICE); if (windowService instanceof WindowManager) { Display display = ((WindowManager) windowService).getDefaultDisplay(); device.put("resolution", display.getWidth() + "x" + display.getHeight()); device.put("orientation", display.getOrientation()); } device.put("display", Build.DISPLAY); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); device.put("product", Build.PRODUCT); device.put("build.type", Build.TYPE); device.put("android.version", Build.VERSION.SDK_INT); }
From source file:org.que.activities.fragments.dialogs.PaperPasswordDialogFragment.java
/** * Set the onClickListener for the submit button, * which submit the authentication for the paper password dialog. * // w w w. java2 s . c o m * @param root the root view, which contains the submit button */ public void setOnClickListenerToSubmitButton(View root) { Button submit = (Button) root.findViewById(R.id.alert_paper_password_submit); final EditText emailText = (EditText) root.findViewById(R.id.alert_paper_password_login); final EditText pwText = (EditText) root.findViewById(R.id.alert_paper_password_pw); submit.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { String url = getString(R.string.alert_paper_password_url); AsyncJSONSender sender = new AsyncJSONSender(url, new AsyncJSONSender.PostExecuteJob() { private boolean failed = false; public void doJob(JSONObject jsonResult) { //TODO paper view call String api = getString(R.string.pref_api_key); try { SharedPreferences pref = getActivity().getSharedPreferences( PaperDetailMenuFragment.class.getName(), Context.MODE_PRIVATE); pref.edit().putString(api, jsonResult.getString(api)).apply(); } catch (JSONException ex) { Log.e(PasswordDialogFragment.class.getName(), "api_key does not exists in JSON Result", ex); } Toast.makeText(getActivity(), "Registered finished!!!", Toast.LENGTH_LONG).show(); } public void doExeptionHandling(Throwable t) { if (t != null) { PaperPasswordDialogFragment.this.getDialog().cancel(); } failed = true; } public void doFinalJob() { if (failed) { if (getActivity() != null) { Toast.makeText(getActivity(), getString(R.string.alert_pw_register_failed), Toast.LENGTH_LONG).show(); } } else { PaperPasswordDialogFragment.this.getDialog().cancel(); } } }); String os = String.format(getString(R.string.alert_email_device_os), Build.VERSION.RELEASE); PaperPasswordPayload payload = new PaperPasswordPayload(emailText.getText().toString(), os, Build.MODEL, pwText.getText().toString()); sender.execute(payload.toJSON()); } }); }
From source file:org.droidmate.uiautomator2daemon.UiAutomator2DaemonDriver.java
private DeviceResponse getDeviceModel() { Log.d(uiaDaemon_logcatTag, "getDeviceModel()"); String model = Build.MODEL; String manufacturer = Build.MANUFACTURER; DeviceResponse deviceResponse = new DeviceResponse(); deviceResponse.model = manufacturer + "-" + model; Log.d(uiaDaemon_logcatTag, "Device model: " + deviceResponse.model); return deviceResponse; }