Example usage for android.content Context TELEPHONY_SERVICE

List of usage examples for android.content Context TELEPHONY_SERVICE

Introduction

In this page you can find the example usage for android.content Context TELEPHONY_SERVICE.

Prototype

String TELEPHONY_SERVICE

To view the source code for android.content Context TELEPHONY_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.telephony.TelephonyManager for handling management the telephony features of the device.

Usage

From source file:Main.java

public static String getImei(Context context) {
    String imei;//www .  j a v a2 s  .c o  m
    try {
        imei = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    } catch (Exception e) {
        imei = "myTrace";
    }
    return imei;
}

From source file:Main.java

public static String getDeviceID(Context context) {
    String id = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    if (TextUtils.isEmpty(id)) {
        id = "000000000000000";
    }//from  w ww .  j a v a 2  s  .co  m
    return id;
}

From source file:Main.java

public static String getIMEI(Context context) {
    try {/*w  w w  . ja  va 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 boolean isPad() {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
        return true;
    } else {/*from w  ww  . j a v a2s. co  m*/
        return false;
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getPhoneIMEI(Context cxt) {
    TelephonyManager tm = (TelephonyManager) cxt.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getDeviceId();
}

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;
    }//from w ww .ja v  a2s . co  m
    return false;
}

From source file:Main.java

public static String getDeviceId(Context context) {
    String deviceId = "";
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    deviceId = tm.getDeviceId();/*from   w  w  w.j a  va 2  s . c om*/
    return deviceId;
}

From source file:Main.java

public static String getSimOperatorName(Context context) {
    return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSimOperatorName();
}

From source file:Main.java

public static String getDeviceId(Context context) {

    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    Log.d("AppUtils", "getDeviceId:" + tm.getDeviceId());

    return tm.getDeviceId();
}