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 boolean isEmulator() {
    TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    if (imei == null || imei.equals("000000000000000")) {
        return true;
    }/* ww  w .  j  a v  a2s.  co  m*/
    return false;
}

From source file:Main.java

public static String getDeviceId(Context context) {
    String deviceId = "";
    try {//  w  w  w  .  ja  va2s .c o  m
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        deviceId = tm.getDeviceId();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return deviceId;
}

From source file:Main.java

public static String ConfigureGetIMEI(Context context) {
    if (null == context) {
        return "";
    }//www  .ja  v a2s .  co m
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    if (imei == null)
        imei = "";
    return imei;
}

From source file:Main.java

public static String getDeviceId(Context context) {
    if (TextUtils.isEmpty(DEVICE_ID)) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        DEVICE_ID = tm.getDeviceId();
    }/*  w w  w .ja v a2  s .  c o  m*/
    return DEVICE_ID;
}

From source file:Main.java

public static String configureGetIMEI(Context context) {
    if (null == context) {
        return "";
    }/*  www .j a va2  s .c o  m*/
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    if (imei == null)
        imei = "";
    return imei;
}

From source file:Main.java

public static String getImei(Context ctx) {
    TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

    return telephonyManager.getDeviceId();
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = manager.getDeviceId();
    if (imei == null)
        imei = "";
    return imei;// w  w w . j  av a2  s  . c om
}

From source file:Main.java

public static String getDeviceId(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String id = telephonyManager.getDeviceId();
    return id == null ? "unknown device id" : id;
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = mTelephonyMgr.getDeviceId();
    return imei;/*from  w  ww . j a  va2 s.c om*/
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager mgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceId = mgr.getDeviceId();
    if (deviceId != null) {
        return deviceId;
    }/*from  w ww.j ava 2 s.  c  om*/
    return "";
}