Reputation: 18760
I have a dual sim Android phone. Using this solution I retrieve IMEI numbers of both sims.
Given the IMEI number, how can I find out the phone number of each sim?
There are methods getDeviceIdGemini(int slotId)
and getSimStateGemini(int slotId)
it is possible to find out the IMEI number and the state of each sims.
I'm looking for a similar method for reading the phone number of the sim.
Upvotes: 2
Views: 16596
Reputation: 18760
Using reflection, I looked at the methods of TelephonyManager
and found this method: int getLine1NumberGemini(int)
.
I tried to invoke it (getLine1NumberGemini(0)
for first sim and getLine1NumberGemini(1)
for the second). In both cases I received an empty string.
But the reason for this seems to be the inability of the phone to get the phone number of my sims:
TelephonyManager.getLine1Number()
returns empty string as well.Upvotes: 1
Reputation: 3225
No,
Android doesn't support dual sim devices.
See: Detect the status of two SIM cards in a dual-SIM Android phone
as Android does not support multiple SIMs, at least from the SDK.
You can contact your device manufacturer and see if they have an SDK add-on or something that allows you to access the second SIM.May be an API which can help youto get your desired result.
Although you can find out the status of the device whether it is Dual sim or not by using this link Android : Check whether the phone is dual SIM
Upvotes: 1
Reputation: 93728
Programmatically obtain the phone number of the Android phone
Basic answer- there is no way to get your current phone number. There's things that sometimes work, but not always and not on all carriers.
Upvotes: 2
Reputation: 21657
You can't. Phone number it's not stored on sim card, it's stored on operator's servers. Look for TelephonyManager.getSubscriberId()
, this will give the unique id for each SIM.
Upvotes: 2