Reputation: 2605
I am trying to get the user's phone number but the problem is that I am getting null response based on my research so far we can get the same by using the object of TelePhony Manager and calling function getLine1Number()
but I am not getting any response,somebody suggested that this is because the service provider is not providing the same in my country I am in India but for blackberry it's providing the phone number so what could be the possible problem please suggest my whole algo depends on this.
Upvotes: 1
Views: 182
Reputation:
Add this permission to your android manifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE">
</uses-permission>
use following code to get number
number = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Upvotes: 0
Reputation: 146
have you tried using
String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
If you have already used this, I will recommend that you elaborate your question in a more specific way.
Upvotes: 0
Reputation: 5266
Have you added the permission
<uses-permission android:name="android.permission.READ_PHONE_STATE">
</uses-permission>
to your AndroidManifest.xml file?
Upvotes: 1