Retrieving SIM ID
After searching the API and no luck, mybe anyone开发者_JAVA百科 know how could I retrieve the SIM ID of the device?
thanks,
ray.
Here is the code to get International Mobile Subscriber Identity (IMSI No.) id and phone id (IMEI No.) and Sim No. programmatically
Before doing this also set the user permission in the manifest file "android.permission.READ_PHONE_STATE"
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();
String simno = mTelephonyMgr.getSimSerialNumber();
Log.v("", ""+imsi);
Log.v("", ""+imei);
Log.v("", ""+simno);
Frrom wikiPedia
The Id = Issuer identification number (IIN) Maximum of seven digits: Major industry identifier (MII), 2 digits, 89 for telecommunication purposes. Country code, 1-3 digits, as defined by ITU-T recommendation E.164. Issuer identifier, 1-4 digits.
so the API is :
public String getSimCountryIso ()
public String getSimSerialNumber ()
public String getSubscriberId ()
To retrieve the IMSI (subscriber ID in the SIM), Use the getSubscriberId method in the TelephonyManager API.
精彩评论