List of usage examples for android.telephony TelephonyManager getDeviceId
@Deprecated
@SuppressAutoDoc
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getDeviceId()
From source file:Main.java
public static String getImei(Context context, String imei) { try {/*from w w w . j a va 2s. c o m*/ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } catch (Exception e) { e.printStackTrace(); } return imei; }
From source file:Main.java
public static String getImei(Context context) { String imei = ""; try {/*w w w. j a v a 2 s . c o m*/ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } catch (Exception e) { } return imei; }
From source file:Main.java
/** * Get device Id<br>/*www . j a v a2 s . co m*/ * <b>Will work only on mobile and NOT tablets</b> * * @param context * @return */ public static String getDeviceId(Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceid = tm.getDeviceId(); if (deviceid == null) { deviceid = getUniqueId(context); } return deviceid; }
From source file:Main.java
public static String getDeviceIMEI(Context context) { try {/*w w w. j ava2s . c om*/ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getDeviceId(); } catch (Exception e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static String getImei(Context context) { String imei = ""; try {// w ww . j av a2s .co m TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } catch (Exception e) { e.printStackTrace(); } return imei; }
From source file:Main.java
/** * Uses the telephony manager to understand if the client is running on a * simulator or a real device. On the simulator the device id is a 15 chars * long 0 sequence (os < 2.1).//ww w. ja v a 2 s . com * @param context the application Context * @return true if the device id is a 0s sequence, false otherwise. */ public static boolean isSimulator(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = tm.getDeviceId(); return "000000000000000".equals(deviceId); }
From source file:Main.java
public static String getDeviceInfo(Context context) { try {// ww w. ja v a 2 s. c o m org.json.JSONObject json = new org.json.JSONObject(); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String device_id = tm.getDeviceId(); WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); String mac = wifi.getConnectionInfo().getMacAddress(); json.put("mac", mac); if (TextUtils.isEmpty(device_id)) { device_id = mac; } if (TextUtils.isEmpty(device_id)) { device_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } json.put("device_id", device_id); return json.toString(); } catch (Exception e) { e.printStackTrace(); } return null; }
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 getIMEI() { checkNull();//from w w w. jav a2 s . c om TelephonyManager telephonyManager = (TelephonyManager) matoContext .getSystemService(Context.TELEPHONY_SERVICE); String imei = telephonyManager.getDeviceId(); return imei == null ? "null" : imei; }
From source file:Main.java
public static String getDeviceId(Context ctx) { TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); String deviceid = telephonyManager.getDeviceId(); return deviceid; }