Get a program number in Android software
This code can find the sim number, but only if the number is stored by our phone or we can never find the sim number anyway.
TelephonyManager telephonyManager = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
mobile number = telephonyManager.getLine1Number();
In fact, only those devices that have saved their SIM number are impossible. The OTP verification procedure is best for this, please enter your number and receive your fingerprint for verification.
source to share
Try the code to get sim serial number and get sim number
TelephonyManager tManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = tManager.getSimSerialNumber();
String getSimNumber = tManager.getLine1Number();
Log.v(TAG, "getSimSerialNumber : " + getSimSerialNumber +" ,getSimNumber : "+ getSimNumber);
Add below permission to your Androidmanifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
source to share
You can find the first sim number using this code.
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mobileNumber = telephonyManager.getLine1Number();
Add this uses-permission
to your manifest as well.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
This code will help you, but will not return the exact result for a while. The best option is to check the number after asking the user for a mobile phone number.
It will help you, it helped me.
source to share