I want to know user mobile number in Android. I used this code but I'm not getting number.
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String n = tm.getLine1Number();
Permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Is it compulsory to save number in android mobile settings --> about phone --> status --> myphone number
Any idea on this?
I think sim serial Number and sim number is unique. You can try this for get sim serial number and get sim number and Don't forget to add permission in manifest file.
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
String getSimNumber = telemamanger.getLine1Number();
And add below permission into your Androidmanifest.xml
file.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Let me know if there is any issue.