3

I want to verify that user cell number is same as the sim number used in the device during registration in android application.

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

If it is impossible then any other verification process?

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
G Mehdi Balti
  • 154
  • 2
  • 12
  • 5
    Possible duplicate of [How to get current SIM card number in Android?](https://stackoverflow.com/questions/14051023/how-to-get-current-sim-card-number-in-android) – King of Masses Jul 25 '17 at 12:04

3 Answers3

2

This code can find the sim number but only if the number is saved our phone directory or we can never find the sim number in any case.

 TelephonyManager telephonyManager = (TelephonyManager) 
 getSystemService(Context.TELEPHONY_SERVICE);
 mobile number = telephonyManager.getLine1Number();

Really it is impossible only those device which has saved their sim number can possible. OTP verification process is best for this , please enter your number and get a otp to verify.

Dinithe Pieris
  • 1,822
  • 3
  • 32
  • 44
0

Try following 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 into your Androidmanifest.xml

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Aj 27
  • 2,316
  • 21
  • 29
0

You can find the first sim number using this code.

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mobileNumber = telephonyManager.getLine1Number();

Add this uses-permission also in manifest.

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

This code will help you but some time it does not return the exact result. Best option is to verify the number after asking the user for their mobile number.

This would help you, it has helped me.

RobVoisey
  • 1,083
  • 15
  • 24
Mayank Garg
  • 1,284
  • 1
  • 11
  • 23