Algeroth
Algeroth

Reputation: 785

How get my phone number on android using CallLog

In my app I'm using CallLog's and I'm getting data of calls. I can receive all data, but there is no information about my number phone. How can I receive this information? getLine1Number() from TelephonyManager return empty string..

Upvotes: 2

Views: 145

Answers (3)

Riskhan
Riskhan

Reputation: 4470

It depends on Mobile Operator. In India Airtel support this feature.

Upvotes: 1

dindinii
dindinii

Reputation: 655

To get the phone number from the device , first you have to set your own phone number on the device, just through :

Settings -> About Phone -> Status -> My phone Number

Phone numbers are not available on SIM for each operators, like in india Sim dont have phone numbers in any memory, So WE cant get phone number from these connection. However, some countries, and operators have stored phone numbers on SIM, and we can get those.

Upvotes: 2

Ishita Sinha
Ishita Sinha

Reputation: 2294

Yes. This is because not all operators support retrieving phone number from the SIM card. There is no fail-safe way to always retrieve the phone number through your app. Your best bet is to ask the user to enter their phone number into the app and then save it to shared preferences or something.

Upvotes: 1

Related Questions