2

I'm implementing a payment app. So for contact verification I have to find the contact number. Also i'm sending a sms from sim for cross verification on server. I have tried

> TelephonyManager tm =
> (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
> String phoneNumber=  tm.getLine1Number();

but I'm unable to get contact number. I have also implemented broadcast receiver to check weather sms sent or delivered. So is there any way to get the contact number or not?

1 Answers1

1

Have you defined this permission in manifest:

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

Also use getActivity().getApplicationContext(); in place of this.getApplicationContext() if you are using fragment

kgandroid
  • 5,507
  • 5
  • 39
  • 69