0

I used nokia 6 which is android 8.1.0 . i used this code for finding my phone number

TelephonyManager tel= (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String PhoneNumber =  tel.getLine1Number();
Toast.makeText(getApplicationContext(), PhoneNumber ,Toast.LENGTH_LONG).show();

but it return empty (""). on an other hand it's work fine my emulator. Please any one help me for this oreo solution.

In AndroidManifest.xml, give the following permission:

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
  • please check https://stackoverflow.com/questions/15243278/android-get-all-contacts-telephone-number-in-arraylist and http://www.zeustechnocrats.com/android-read-contact-and-display-in-listview/ also https://www.concretepage.com/android/android-read-contact-name-and-phone-number-using-cursorloader-exampleAnd is there any contact available in your contact list? – Developer Nov 17 '18 at 07:09
  • actually i need my current use number from my phone not contact list – Jahir Remon Nov 17 '18 at 07:15

0 Answers0