Reputation: 51
In my application I want to retrive the device phone number. I used Phone.getDevicePhoneNumber(true)
It is working in the simulator, but when I test on the device it returns an empty string. Is there any other option for getting the device phone number?
I am using jde 4.5.0.
Upvotes: 2
Views: 1381
Reputation: 3065
Phone.getDevicePhoneNumber(true) reads the number from the SIM card. The problem is the number isn't always on the SIM card. I've also seen cases where the wrong number is on the SIM card.
There is no guaranteed way to programmatically get the number. What I've done in the past is present the SIM card number to the user and asked them to correct/confirm it.
Upvotes: 1
Reputation: 11876
The straightforward approach would be to ask the user to enter their phone number.
Upvotes: 2