Example usage for android.telephony TelephonyManager getDeviceId

List of usage examples for android.telephony TelephonyManager getDeviceId

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getDeviceId.

Prototype

@Deprecated
@SuppressAutoDoc 
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getDeviceId() 

Source Link

Document

Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.

Usage

From source file:Main.java

public static String getDefaultUsername(Context ctx) {

    TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String did = telephonyManager.getDeviceId();

    return String.valueOf(did);

}

From source file:Main.java

public static String getPhoneIMEI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String IMEI = telephonyManager.getDeviceId();
    return IMEI;/*from w w  w  . ja v a  2s. c o  m*/
}

From source file:Main.java

public static String getDeviceId(TelephonyManager tm) {
    String id = tm.getSubscriberId();
    if (TextUtils.isEmpty(id)) {
        id = tm.getDeviceId();
    }//w w  w  . ja  va2 s  .com
    if (TextUtils.isEmpty(id)) {
        id = UUID.randomUUID().toString();
    }
    return id;
}

From source file:Main.java

public static String getPhoneImei(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    return imei;/*from   w w w. ja v a 2s  .  c o m*/
}

From source file:Main.java

public static String getIMEI(Context context) {
    try {// w w w  . ja  v  a  2 s.c  o  m
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imeiCode = tm.getDeviceId();
        return imeiCode;
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static boolean isEmulator(Context context) {
    try {/*  ww  w  .ja  va 2s  .com*/
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = tm.getDeviceId();
        if (imei != null && imei.equals("000000000000000"))
            return true;

        return (Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk"));
    } catch (Exception ioe) {
        return false;
    }
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = mTelephonyMgr.getDeviceId();
    if (TextUtils.isEmpty(imei) || imei.equals("000000000000000")) {
        imei = "0";
    }/* w  w w .  ja  va 2s  .  co  m*/
    return imei;
}

From source file:Main.java

public static boolean isEmulator(Context context) {
    try {/*from  w ww  . j  av  a 2 s .  c o  m*/
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = tm.getDeviceId();
        if (imei != null && imei.equals("000000000000000")) {
            return true;
        }
        return (Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk"));
    } catch (Exception ioe) {
    }
    return false;
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imeisv = telephonyManager.getDeviceId();
    if (imeisv == null)
        imeisv = "Unknown";
    return imeisv;
}

From source file:Main.java

public static String getLocalIMEINo(Context context) {
    String NativeIMEINumber = null;
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    NativeIMEINumber = telephonyManager.getDeviceId();
    return NativeIMEINumber;
}