Example usage for android.telephony TelephonyManager getSubscriberId

List of usage examples for android.telephony TelephonyManager getSubscriberId

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getSubscriberId.

Prototype

@SuppressAutoDoc 
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getSubscriberId() 

Source Link

Document

Returns the unique subscriber ID, for example, the IMSI for a GSM phone.

Usage

From source file:Main.java

public static String getImsi(TelephonyManager tm) {
    String imsi = tm.getSubscriberId();
    return imsi == null ? "" : imsi;
}

From source file:Main.java

public static String getDeviceId(TelephonyManager tm) {
    String id = tm.getSubscriberId();
    if (TextUtils.isEmpty(id)) {
        id = tm.getDeviceId();// www .  java2  s  .c o  m
    }
    if (TextUtils.isEmpty(id)) {
        id = UUID.randomUUID().toString();
    }
    return id;
}

From source file:Main.java

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

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(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
    return manager.getSubscriberId();
}

From source file:Main.java

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

From source file:Main.java

public static String getIMSI(Context context) {

    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imsi = tm.getSubscriberId();
    return imsi;/*from   w  w  w.  j  a  v a2 s  . co m*/
}

From source file:Main.java

public static String getSubscriberId(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tel = tm.getSubscriberId();
    return TextUtils.isEmpty(tel) ? "" : tel;
}

From source file:Main.java

public static String getImsi(Context mContext) {
    TelephonyManager telephonyMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyMgr.getSubscriberId();
}

From source file:Main.java

public static String getIMSI(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getSubscriberId() != null ? tm.getSubscriberId() : null;
}