Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does getLine1Number() return with dual SIM phones?

Tags:

android

What does getLine1Number() method of TelephonyManager return with dual SIM phones like LG Optimus Net Dual?

like image 989
Gaurav Agarwal Avatar asked Jun 25 '12 22:06

Gaurav Agarwal


2 Answers

You'll get back only one number ... maybe!

First, which number you get back is device dependent.

But equally importantly whether you will get a number at all, and whether this number will be the phone number, is completely unpredictable. This is SIM and operator dependent.

In one of my apps, I started off trying to use the phone number as a unique ID, since I could expect the user to recall this number easily. For most operators in Asia, Australia and some in Europe, the phone number (line1number()) is simply not stored on the SIM! With others, you may get a string of zeroes. Or a number formatted in a way that may make sense locally but could mess up your app's logic.

like image 90
PVS Avatar answered Oct 05 '22 14:10

PVS


Android doesn't support dual sim devices. See: Detect the status of two SIM cards in a dual-SIM Android phone

As someone else said you might get support from device manufacturers.

Additionally getLine1Number() isn't guaranteed to return a phone number. It just returns what the operators store in the card, and some operators don't bother filling in that number. So with some sim cards this would just return null.

If you provide details of what you are trying to achieve we might be able to provide a better solution.

like image 38
chkdsk Avatar answered Oct 05 '22 14:10

chkdsk