List of usage examples for android.os Build ID
String ID
To view the source code for android.os Build ID.
Click Source Link
From source file:com.libframework.annotation.util.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return/*from w w w . j a v a 2 s .com*/ */ public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class<?> sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase(Locale.getDefault())); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase(Locale.getDefault())); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.ddiiyy.xydz.xutils.util.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return//from ww w. j a v a 2 s. c o m */ @SuppressLint("DefaultLocale") @SuppressWarnings("rawtypes") public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase()); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase()); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.anysoftkeyboard.ui.dev.DeveloperUtils.java
public static String getSysInfo(@Nullable Context context) { StringBuilder sb = new StringBuilder(); sb.append("BRAND:").append(Build.BRAND).append(NEW_LINE); sb.append("DEVICE:").append(Build.DEVICE).append(NEW_LINE); sb.append("Build ID:").append(Build.DISPLAY).append(NEW_LINE); sb.append("changelist number:").append(Build.ID).append("\n"); sb.append("MODEL:").append(Build.MODEL).append(NEW_LINE); sb.append("PRODUCT:").append(Build.PRODUCT).append(NEW_LINE); sb.append("TAGS:").append(Build.TAGS).append(NEW_LINE); sb.append("VERSION.INCREMENTAL:").append(Build.VERSION.INCREMENTAL).append(NEW_LINE); sb.append("VERSION.RELEASE:").append(Build.VERSION.RELEASE).append(NEW_LINE); sb.append("VERSION.SDK_INT:").append(Build.VERSION.SDK_INT).append(NEW_LINE); if (context != null && context.getResources() != null && context.getResources().getConfiguration() != null) { Configuration configuration = context.getResources().getConfiguration(); sb.append("Locale:").append(configuration.locale).append(NEW_LINE); sb.append("configuration:").append(configuration.toString()).append(NEW_LINE); }//from ww w .ja va 2 s . c o m sb.append("That's all I know."); return sb.toString(); }
From source file:com.lidroid.xutils.utils.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return//from w ww . j a v a2s . c o m */ @SuppressLint("DefaultLocale") public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class<?> sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase()); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase()); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.cat.external.util.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return/*from www.j av a 2 s . c o m*/ */ @SuppressLint("DefaultLocale") public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { @SuppressWarnings("rawtypes") Class sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase()); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase()); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.ruint.core.utils.OtherUtils.java
/** * @param context/*from w w w.j a v a 2 s. c o m*/ * if null, use the default format (Mozilla/5.0 (Linux; U; Android * %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 * %sSafari/534.30). * @return */ @SuppressWarnings("rawtypes") public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase()); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase()); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.android.test.gallery3d.common.HttpClientFactory.java
private static String getUserAgent(Context context) { if (sUserAgent == null) { PackageInfo pi;//from w w w . ja va2 s . c o m try { pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { throw new IllegalStateException("getPackageInfo failed"); } sUserAgent = String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", pi.packageName, pi.versionName, Build.BRAND, Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK, Build.VERSION.RELEASE, Build.VERSION.INCREMENTAL); } return sUserAgent; }
From source file:com.android.fastergallery.common.HttpClientFactory.java
private static String getUserAgent(Context context) { if (sUserAgent == null) { PackageInfo pi;/*from w w w . j av a 2 s.co m*/ try { pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { throw new IllegalStateException("getPackageInfo failed"); } sUserAgent = String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", pi.packageName, pi.versionName, Build.BRAND, Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK_INT, Build.VERSION.RELEASE, Build.VERSION.INCREMENTAL); } return sUserAgent; }
From source file:com.apptentive.android.sdk.storage.DeviceManager.java
private static Device generateNewDevice(Context context) { Device device = new Device(); // First, get all the information we can load from static resources. device.setOsName("Android"); device.setOsVersion(Build.VERSION.RELEASE); device.setOsBuild(Build.VERSION.INCREMENTAL); device.setOsApiLevel(String.valueOf(Build.VERSION.SDK_INT)); device.setManufacturer(Build.MANUFACTURER); device.setModel(Build.MODEL);//from w w w. j a v a2 s.c o m device.setBoard(Build.BOARD); device.setProduct(Build.PRODUCT); device.setBrand(Build.BRAND); device.setCpu(Build.CPU_ABI); device.setDevice(Build.DEVICE); device.setUuid(GlobalInfo.androidId); device.setBuildType(Build.TYPE); device.setBuildId(Build.ID); // Second, set the stuff that requires querying system services. TelephonyManager tm = ((TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE))); device.setCarrier(tm.getSimOperatorName()); device.setCurrentCarrier(tm.getNetworkOperatorName()); device.setNetworkType(Constants.networkTypeAsString(tm.getNetworkType())); // Finally, use reflection to try loading from APIs that are not available on all Android versions. device.setBootloaderVersion(Reflection.getBootloaderVersion()); device.setRadioVersion(Reflection.getRadioVersion()); device.setLocaleCountryCode(Locale.getDefault().getCountry()); device.setLocaleLanguageCode(Locale.getDefault().getLanguage()); device.setLocaleRaw(Locale.getDefault().toString()); device.setUtcOffset(String.valueOf((TimeZone.getDefault().getRawOffset() / 1000))); return device; }
From source file:name.setup.dance.DanceStepApp.java
/** Called when the activity is first created. */ @Override//from ww w . j ava 2 s . co m public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "[ACTIVITY] onCreate"); super.onCreate(savedInstanceState); //mStepValue = 0; mPaceValue = 0; setContentView(R.layout.main); mUtils = Utils.getInstance(); String m_szDevIDShort = "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 mUtils.DeviceName = m_szDevIDShort; Log.v(TAG, "ID: " + m_szDevIDShort); Log.v(TAG, "UTILS: " + mUtils.DeviceName); // user name mTextField = (EditText) findViewById(R.id.name_area); mTextField.setCursorVisible(false); if (!(mUtils.UserName == "My Name")) { mTextField.setText(mUtils.UserName); } mTextField.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // only will trigger it if no physical keyboard is open mgr.showSoftInput(mTextField, InputMethodManager.SHOW_IMPLICIT); mTextField.requestFocus(); mTextField.setCursorVisible(true); mOkayButton.setVisibility(View.VISIBLE); } }); // init okay Button mOkayButton = (Button) findViewById(R.id.okay_button); mOkayButton.setVisibility(View.INVISIBLE); mOkayButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); mTextField.setCursorVisible(false); mTextField.clearFocus(); mUtils.UserName = mTextField.getText().toString(); // post name via HHTP new Thread(new Runnable() { public void run() { if (mIsMetric) { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue); } else { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue * 1.609344f); } } }).start(); mOkayButton.setVisibility(View.INVISIBLE); // Post TOAST MESSAGE Toast.makeText(getApplicationContext(), getText(R.string.name_saved), Toast.LENGTH_SHORT).show(); } }); // init Score Button mScoreButton = (Button) findViewById(R.id.scoreButton); mScoreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click String url = "http://www.setup.nl/tools/dancestep_app/index.php?id=" + mUtils.DeviceName + "&time=" + System.currentTimeMillis(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); }