The class TelephonyManager provides information about the telephony service and the device. An Android app can use the methods of this class to determine the sim number and its serial number, for example.
The method getLine1Number() returns the phone number for line 1 and returns null if the MISISDN is unavailable.
You must also add the permission in the file Androidmanifest.xml:
TelephonyManager telemamanger=(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
String getSimNumber = telemamanger.getLine1Number();
< uses-permission android:name="android.permission.READ_PHONE_STATE"/>References:
http://stackoverflow.com/questions/8570945/get-msisdn-from-the-sim-using-android
Commentaires (12)
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Excellent tutoriel !
N'hésitez pas si vous avez des questions.