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 getUserDeviceID(Context context) {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceId = telephony.getDeviceId();
    return deviceId;
}

From source file:Main.java

public static String getImei(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();
    return imei;//w ww  .java  2s . c  o  m
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceId = telManager.getDeviceId();
    return TextUtils.isEmpty(deviceId) ? "" : deviceId;
}

From source file:Main.java

/**
 * Use for getting your device id if available.
 *
 * @param context//from   w w w.java 2 s . c om
 * @return your device id
 */
public static String getDeviceId(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getDeviceId();
}

From source file:Main.java

/**
 * @param context/*from   ww  w  .j  av  a2  s .c  o  m*/
 * @return device token/id
 */
public static String getDeviceID(Context context) {
    // TODO Auto-generated method stub
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getDeviceId();
}

From source file:Main.java

public static String IMEI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String IMEI = telephonyManager.getDeviceId();
    return IMEI;//w ww.j a  v a 2  s  .co m
}

From source file:Main.java

public static String getDeviceId(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceId = tm.getDeviceId();
    if (deviceId == null) {
        return "-";
    } else {/*  ww  w  .  j  ava2s .  c o  m*/
        return deviceId;
    }
}

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  www. j a  v  a2  s .c  o m
}

From source file:Main.java

public static String getIMEI(Context context) {
    try {//from   w w  w.j  a v  a  2 s.c om
        TelephonyManager telephoneMngr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return telephoneMngr.getDeviceId();
    } catch (Exception e) {
        return "000000000000000";
    }
}

From source file:Main.java

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