- Forum posts: 11
Jun 8, 2017, 11:51:22 AM via Website
Jun 8, 2017 11:51:22 AM via Website
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 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);
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.