Java - Recover Sim Card Number on Android
There is no reliable solution to this problem because the phone number is not physical and stored in the sim card, or retrieved from the carrier's network. The best solution is to ask the user to enter their number themselves. Here we give a solution but one that remains to be improved in the future.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