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 boolean isSimUsable(final Context context) {

    TelephonyManager telephonyManager1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    int simState = telephonyManager1.getSimState();
    switch (simState) {
    case TelephonyManager.SIM_STATE_READY:
        return true;
    }/*from   w  w  w  .  j av a2 s . com*/

    return false;

}

From source file:Main.java

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

From source file:Main.java

public static String getIMSI() {
    TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager.getSubscriberId() == null) {
        return null;
    } else {//  w w w  .  j a v  a  2  s.  c o  m
        return telephonyManager.getSubscriberId();
    }
}

From source file:Main.java

public static TelephonyManager getManager(final Context context) {
    return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}

From source file:Main.java

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

From source file:Main.java

public static String getPhoneNumber(Context cx) {
    String phoneNumber = "";
    try {/*  ww w . j  av a  2  s .c o  m*/
        phoneNumber = ((TelephonyManager) cx.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
    } catch (Exception e) {
    }
    return phoneNumber;
}

From source file:Main.java

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

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getApplicationContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    return manager.getSimSerialNumber();
}

From source file:Main.java

public static String getSN(Context context) {
    final String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
            .getDeviceId();/*from w w  w . j a  v a 2 s .  co m*/
    if (deviceId != null) {
        return deviceId;
    } else {
        return android.os.Build.SERIAL;
    }
}

From source file:Main.java

public static String getIMSI(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getApplicationContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    return manager.getSubscriberId();
}