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 getDeviceID(Context context) {
    TelephonyManager mngr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceID = mngr.getDeviceId();
    return deviceID;
}

From source file:Main.java

public static String queryCountryCode(Context context) {
    TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tel.getNetworkCountryIso();
}

From source file:Main.java

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

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) {
        deviceId = tm.getSubscriberId();
    }// w w w .  j a va 2s  .c  o m
    return deviceId;
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager tMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tMgr.getLine1Number();
}

From source file:Main.java

public static String getPhoneNumber(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String phoneNumber = tm.getLine1Number();
    if (phoneNumber == null || phoneNumber.length() == 0) {
        return null;
    }/*  w  w  w . j av a2  s .  co  m*/
    phoneNumber = phoneNumber.replace("+82", "0");
    return phoneNumber;
}

From source file:Main.java

public static String getIMEI(Context context) {
    TelephonyManager mgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String deviceId = mgr.getDeviceId();
    if (deviceId != null) {
        return deviceId;
    }/*from w  ww  . j  av a 2  s.  c o  m*/
    return "";
}

From source file:Main.java

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

From source file:Main.java

public static String getOperationName(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getNetworkOperatorName() == null ? "" : tm.getNetworkOperatorName();
}

From source file:Main.java

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