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 getIMSI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String IMSI = telephonyManager.getSubscriberId();
    if (IMSI == null) {
        IMSI = "";
    }/*  w w  w  .ja  v a  2 s.  co  m*/
    return IMSI;
}

From source file:Main.java

public static boolean isPhone(Context context) {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
        return false;
    } else {/*  www. ja  v a2  s.  c  o m*/
        return true;
    }
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String phoneNumber = phoneMgr.getLine1Number();
    if (null == phoneNumber) {
        return "";
    } else {//w  ww .  j  a va2s  .  c  om
        return phoneNumber;
    }
}

From source file:Main.java

public static final String getPhoneNumber(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String number = tm.getLine1Number();
    if (number == null) {
        return "";
    }//from   www .j av a 2  s. co  m
    return number;
}

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;//from   w  ww.j av a 2s.  com
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String childMobile = phoneMgr.getLine1Number();
    if (childMobile == null) {
        return null;
    } else {/*from   w  ww . ja va2s . c  o  m*/
        return childMobile;
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getDefaultUsername(Context ctx) {

    TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String did = telephonyManager.getDeviceId();

    return String.valueOf(did);

}