Get a program number in Android software

I want to check that the user's cell number matches the sim number used in the device during registration in the Android app.

How do I get the sim number in my application to compare with the user entered number?

If this is not possible, then any other verification process?

+3


source to share


3 answers


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.

+2


source


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"/>

      

0


source


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.

0


source







All Articles