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 getPhoneDeviceId(Context context) {
    TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telManager == null ? null : telManager.getDeviceId();
}

From source file:Main.java

public static String getIMSICode(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getSubscriberId();
}

From source file:Main.java

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

From source file:Main.java

public static String getMyPhoneNumber(Activity _act) {
    return ((TelephonyManager) _act.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
}

From source file:Main.java

public static boolean isInSystemCall(Context context) {
    TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telManager == null)
        return false;
    return (telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE);
}

From source file:Main.java

public static int getNetworkType(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getNetworkType();
}

From source file:Main.java

public static String getSimNumber(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getSimSerialNumber();
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tel = phoneMgr.getLine1Number();
    if (tel != null) {
        tel = tel.replace("+86", "").trim();
    }/*from w  w  w.j  a va2  s .  c o m*/
    return tel;
}

From source file:Main.java

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

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;// w ww .ja  v  a  2s  . com
}