-3

I tried to get mobile number by using TelephonyManager but it returns null. But I am amazed that Viber app is showing mobile number along with country code. If there is any trick or tips to make my app get the mobile number like viber?

Tek Raj
  • 323
  • 1
  • 3
  • 8

2 Answers2

1

To get phone number

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); String number = tm.getLine1Number();

but have you provided the permission in the manifest.

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

This always does not return the number. you can get some idea here, by sending a SMS.

Community
  • 1
  • 1
droid
  • 414
  • 2
  • 7
  • 21
  • This returns null in my case. But viber shows mobile number with country code. – Tek Raj Dec 23 '14 at 06:24
  • Can you just add the code snippet you are using with your manifest. – droid Dec 23 '14 at 06:29
  • everything is done. The network provider in Nepal does not allow to access mobile number programatically. But viber is getting it. – Tek Raj Dec 23 '14 at 06:39
  • I haven't use viber yet, not much idea, but it can be a case if you get the SMS(content provider) and from there you can get the numbers sent and from , you can get something. Did you got it? – droid Dec 23 '14 at 06:46
  • wait i tot, with viber you register with your number and they save it on their server, with your friends are your contacts which they synchronise with their servers....@TekRaj – Elltz Dec 23 '14 at 07:55