get phone Imsi - Android android.telephony

Android examples for android.telephony:TelephonyManager

Description

get phone Imsi

Demo Code

import android.content.Context;
import android.telephony.TelephonyManager;

public class Main {

  public static String getImsi(Context context) {
    String imsi = null;//  w w  w.  j a va 2s.co  m
    TelephonyManager phoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (phoneManager != null)
      imsi = phoneManager.getSubscriberId();
    if (imsi == null)
      imsi = "";
    return imsi;
  }

}

Related Tutorials