List of usage examples for android.os Build BRAND
String BRAND
To view the source code for android.os Build BRAND.
Click Source Link
From source file:Main.java
/** * Return pseudo unique ID//from w w w .jav a 2s. c o m * @return ID */ public static String getUniquePsuedoID() { // If all else fails, if the user does have lower than API 9 (lower // than Gingerbread), has reset their phone or 'Secure.ANDROID_ID' // returns 'null', then simply the ID returned will be solely based // off their Android device information. This is where the collisions // can happen. // Thanks http://www.pocketmagic.net/?p=1662! // Try not to use DISPLAY, HOST or ID - these items could change. // If there are collisions, there will be overlapping data String m_szDevIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10); // Thanks to @Roman SL! // http://stackoverflow.com/a/4789483/950427 // Only devices with API >= 9 have android.os.Build.SERIAL // http://developer.android.com/reference/android/os/Build.html#SERIAL // If a user upgrades software or roots their phone, there will be a duplicate entry String serial = null; try { serial = android.os.Build.class.getField("SERIAL").get(null).toString(); // Go ahead and return the serial for api => 9 return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString(); } catch (Exception e) { // String needs to be initialized serial = "serial"; // some value } // Thanks @Joe! // http://stackoverflow.com/a/2853253/950427 // Finally, combine the values we have found by using the UUID class to create a unique identifier return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString(); }
From source file:Main.java
public static String getDeviceId(Context context) { try {/* ww w . j a v a 2s .co m*/ TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String szImei = TelephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE return szImei; } catch (Exception e) { // Oh well } try { 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 return m_szDevIDShort; } catch (Exception e) { // Oh well } return "tempid" + getRandom().nextInt(); }
From source file:Main.java
public static String getPsuedoUniqueID() { String devIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { devIDShort += (Build.SUPPORTED_ABIS[0].length() % 10); } else {//from ww w .j ava2 s . c o m devIDShort += (Build.CPU_ABI.length() % 10); } devIDShort += (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10); String serial; try { serial = Build.class.getField("SERIAL").get(null).toString(); return new UUID(devIDShort.hashCode(), serial.hashCode()).toString(); } catch (Exception e) { serial = "ESYDV000"; } return new UUID(devIDShort.hashCode(), serial.hashCode()).toString(); }
From source file:Main.java
/** * Return pseudo unique ID// w w w. j a v a2s. c o m * * @return ID */ public static String getUniquePsuedoID() { // If all else fails, if the user does have lower than API 9 (lower // than Gingerbread), has reset their phone or 'Secure.ANDROID_ID' // returns 'null', then simply the ID returned will be solely based // off their Android device information. This is where the collisions // can happen. // Thanks http://www.pocketmagic.net/?p=1662! // Try not to use DISPLAY, HOST or ID - these items could change. // If there are collisions, there will be overlapping data String m_szDevIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10); // Thanks to @Roman SL! // http://stackoverflow.com/a/4789483/950427 // Only devices with API >= 9 have android.os.Build.SERIAL // http://developer.android.com/reference/android/os/Build.html#SERIAL // If a user upgrades software or roots their phone, there will be a // duplicate entry String serial = null; try { serial = android.os.Build.class.getField("SERIAL").get(null).toString(); // Go ahead and return the serial for api => 9 return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString(); } catch (Exception e) { // String needs to be initialized serial = "serial"; // some value } // Thanks @Joe! // http://stackoverflow.com/a/2853253/950427 // Finally, combine the values we have found by using the UUID class to // create a unique identifier return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString(); }
From source file:Main.java
public static final String getOblyDevicesID(Context mContext) { String m_szImei = ""; try {/*from www . j av a 2s .c o m*/ TelephonyManager TelephonyMgr = null; TelephonyMgr = (TelephonyManager) mContext.getSystemService(Activity.TELEPHONY_SERVICE); m_szImei = TelephonyMgr.getDeviceId(); } catch (Exception ex) { ex.printStackTrace(); } String m_szDevIDShort = null; try { 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 } catch (Exception ex) { ex.printStackTrace(); } String m_szAndroidID = ""; try { m_szAndroidID = ""; Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID); } catch (Exception ex) { ex.printStackTrace(); } String m_szWLANMAC = ""; try { WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); m_szWLANMAC = wm.getConnectionInfo().getMacAddress(); } catch (Exception ex) { ex.printStackTrace(); } String m_szBTMAC = null; try { BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); m_szBTMAC = m_BluetoothAdapter.getAddress(); } catch (Exception ex) { ex.printStackTrace(); } String m_szLongID = m_szImei + m_szDevIDShort + m_szAndroidID + m_szWLANMAC + m_szBTMAC; // compute md5 MessageDigest m = null; try { m = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } m.update(m_szLongID.getBytes(), 0, m_szLongID.length()); // get md5 bytes byte p_md5Data[] = m.digest(); // create a hex string String m_szUniqueID = new String(); for (int i = 0; i < p_md5Data.length; i++) { int b = (0xFF & p_md5Data[i]); // if it is a single digit, make sure it have 0 in front (proper padding) if (b <= 0xF) m_szUniqueID += "0"; // add number to string m_szUniqueID += Integer.toHexString(b); } // hex string to uppercase m_szUniqueID = m_szUniqueID.toUpperCase(); return m_szUniqueID; }
From source file:Main.java
public static String getUserAgent(Context context) { PackageInfo packageInfo;// ww w. j av a 2 s . c om try { packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { throw new IllegalStateException("getPackageInfo failed"); } return String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", packageInfo.packageName, packageInfo.versionName, Build.BRAND, Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK_INT, Build.VERSION.RELEASE, Build.VERSION.INCREMENTAL); }
From source file:Main.java
/** * Checks whether or not the running device is an emulator. * /*from w w w . j a v a 2 s . co m*/ * @return Boolean indicating if the app is currently running in an * emulator. */ public static boolean isEmulator() { return (Build.BOARD.equals("unknown") && Build.DEVICE.equals("generic") && Build.BRAND.equals("generic")); }
From source file:Main.java
public static String getDeviceId(Context context) { // IMEI, if present TelephonyManager telephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = telephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE if (imei != null) return imei; String devId = "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 return devId; }
From source file:Main.java
public static String collectStats(CharSequence flattenedParams) { StringBuilder result = new StringBuilder(1000); result.append("BOARD=").append(Build.BOARD).append('\n'); result.append("BRAND=").append(Build.BRAND).append('\n'); result.append("CPU_ABI=").append(Build.CPU_ABI).append('\n'); result.append("DEVICE=").append(Build.DEVICE).append('\n'); result.append("DISPLAY=").append(Build.DISPLAY).append('\n'); result.append("FINGERPRINT=").append(Build.FINGERPRINT).append('\n'); result.append("HOST=").append(Build.HOST).append('\n'); result.append("ID=").append(Build.ID).append('\n'); result.append("MANUFACTURER=").append(Build.MANUFACTURER).append('\n'); result.append("MODEL=").append(Build.MODEL).append('\n'); result.append("PRODUCT=").append(Build.PRODUCT).append('\n'); result.append("TAGS=").append(Build.TAGS).append('\n'); result.append("TIME=").append(Build.TIME).append('\n'); result.append("TYPE=").append(Build.TYPE).append('\n'); result.append("USER=").append(Build.USER).append('\n'); result.append("VERSION.CODENAME=").append(Build.VERSION.CODENAME).append('\n'); result.append("VERSION.INCREMENTAL=").append(Build.VERSION.INCREMENTAL).append('\n'); result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n'); result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n'); if (flattenedParams != null) { String[] params = SEMICOLON.split(flattenedParams); Arrays.sort(params);//from ww w . j av a 2 s . c om for (String param : params) { result.append(param).append('\n'); } } return result.toString(); }
From source file:Main.java
/** * This method is used to check if the current device supports Sockets with the KeepAlive flag. * <p>//from w ww. ja va 2s .c o m * As that feature is only missing on Chromium devices, we just check for that * * @return Does the current device support KeepAlive sockets? */ public static boolean deviceSupportsKeepAlive() { return !(Build.MANUFACTURER.toLowerCase().contains("chromium") && Build.BRAND.toLowerCase().contains("chromium")); }