Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to verify that a mobile number is present in current device

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 617
    Answer it

    In my App, i want to verify if the mobile number that the user has entered is present on current device. Like all the banking apps do. Banking apps will not allow you to login if registered mobile is not present on current device.

     

    My question is how to do that. I have tried TelephonyManager API and SubscriptionManager API. Both of them are not giving the mobile number.

    With SubscriptionManager API, i'm able to get the following info, but not the mobile number

     

    SubscriptionManager subscriptionManager = SubscriptionManager.from(getApplicationContext()); List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();

    if(subsInfoList != null){

    Log.d("log", "number of sims = " + subsInfoList.size());

    Log.d("log", "Current list = " + subsInfoList);

         for (SubscriptionInfo subscriptionInfo : subsInfoList) {

              Log.d("log", " Number is " + subscriptionInfo.getNumber());

             tvNumber.setText(subscriptionInfo.getNumber());

        }

    }

    number of sims = 1

    Current list = [{id=1, iccId=89914509009117870249 simSlotIndex=0 displayName=airtel carrierName=airtel nameSource=2 iconTint=-13408298 dataRoaming=1 iconBitmap=android.graphics.Bitmap@326dab88 mcc 404 mnc 45 status 1}]

    Number is  

     

    TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String mobileNumber = tMgr.getLine1Number(); Log.d("log", "mobile number = " + mobileNumber);

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: