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

static String queryDevicePhone(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    return manager.getLine1Number();
}

From source file:Main.java

public static String getOperater(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null || 5 != tm.getSimState()) {
        return "";
    }/* w  w  w .j  av  a 2s.c om*/
    return tm.getSimOperator();
}

From source file:Main.java

public static String getTelephonyMgr(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    return imei.toString();
}

From source file:Main.java

public static String getCarrier(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return manager.getNetworkOperatorName();
}

From source file:Main.java

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

From source file:Main.java

public static String getIMSI(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imsi = mTelephonyMgr.getSubscriberId();
    if (TextUtils.isEmpty(imsi)) {
        imsi = "000000000000000";
    }/*ww  w.ja  v a 2s .  co  m*/
    return imsi;
}

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";
    }//from www  .  j a v a 2s .  c om
    return imei;
}

From source file:Main.java

public static String getDeviceUUID(Context context) {
    TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tManager.getDeviceId();
}

From source file:Main.java

public static String getDeviceID(Context context) {
    TelephonyManager mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = mTm.getDeviceId();
    return imei;//from   w ww. jav  a2 s  .  c o m
}

From source file:Main.java

public static int getPhoneType(Context context) {
    int phoneType = 0;
    try {/*from  w w  w . java2 s.  c  o m*/
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        phoneType = tm.getPhoneType();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return phoneType;
}