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 telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager.getSubscriberId() == null) {
        return null;
    } else {//from w  w w  . j  av  a 2 s  .co m
        return telephonyManager.getSubscriberId();
    }
}

From source file:Main.java

public static String getIMSI(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imsi = mTelephonyMgr.getSubscriberId();

    return imsi;//  w  w w .  j a v a2 s.c  om
}

From source file:Main.java

public static String getIMSI(Context context) {
    String imsi = "";
    try {/*  ww w . ja  va 2 s.  c  om*/
        TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        imsi = mTelephonyMgr.getSubscriberId();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return imsi;
}

From source file:Main.java

public static String getIMSI(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imsi = mTelephonyMgr.getSubscriberId();
    if (TextUtils.isEmpty(imsi)) {
        imsi = "000000000000000";
    }//from   w  w w  .j  a  va 2  s.  com
    return imsi;
}

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  ww. j a  v a 2s .  com
    return IMSI;
}

From source file:Main.java

public static String getIMSI(Context context) {
    String result = "";
    try {/*from ww  w.  j av  a 2  s . c o m*/
        TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        result = telManager.getSubscriberId();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return result;
}

From source file:Main.java

/**
 * get mobile operator/*w ww  .  ja  va2s .c om*/
 * 
 * @param context
 * @return
 */
public static String getMobileCarrier(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
    if (tm.getSubscriberId() != null && tm.getSubscriberId().trim().length() >= 5) {
        return tm.getSubscriberId().substring(0, 5);
    } else {
        return "";
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getIMSI(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String IMSI = telephonyManager.getSubscriberId();
    return IMSI;//w  w  w.  j  av a  2s .  com
}

From source file:Main.java

private static String getPhoneIMSI(Context context) {
    String result = null;// w  w  w.  j a v a2s  . c om
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        result = tm.getSubscriberId();
    } catch (Exception e) {
        Log.w(LOG_TAG, e);
    }

    return result == null ? "" : result;
}