How to get cell phone number in android?


How to get cell phone number in android ? Here is code. but it's not working

TelephonyManager tm = (TelephonyManager)this.getSystemService(this.TELEPHONY_SERVICE); String mobileno = tm.getLine1Number();

can anyone help me to solve this.


You can use these lines of code to fetch cell phone numbers from your phone contacts picker.

try { Intent i = new Intent(Intent.ACTION_PICK,ContactsContract.CommonDataKinds.Phone.CONTENT_URI); startActivityForResult(i, PICK_CONTACT); Toast.LENGTH_SHORT).show(); } catch (Exception e) { Log.d("TAG", "Pick Contact ERROR" + e.toString()); }

and use OnActivityResult to get contacts and save it anywhere you want (Like this)

protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICK_CONTACT && resultCode == RESULT_OK) { Uri contactUri = data.getData(); cursor = getContentResolver().query(contactUri, null, null, null, null); cursor.moveToFirst(); String PhoneNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); String ContactName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));


You can try below code:

TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); String number = tMgr.getLine1Number();

And for this code to work you need Permission:

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


  • How do I create a group with a source_id reference?
  • Fetch only Email contacts from Android Contacts
  • How to attach Bitmap to email android
  • Open camera in part of screen
  • Dismiss keyboard for UITextView without using Return key
  • Msi insaller passing paramenter from command prompt for Set Service Login
  • How to get the profile picture from ProfilePictureView to store in the database
  • Incoming buffer size cannot be set to Tyrus client
  • Intercom.io Custom Attributes for Swift aren't working
  • how is the foreground color changed on just one line of wpf listbox?
  • access website within android code and retrieve a generated image
  • IPhone UIImagepicker with camera showing camera roll thumbnail like default camera app?
  • (MasterCard Virtual Payment Client) migs integration php
  • Angular to update UI from the child component reflect the value to the parent component
  • Remove/Delete particular cache Glide
  • calling onActivityResult from CustomArray adapter
  • Attaching an image to an email
  • How to save image into sql-server using linq?
  • Yahoo transforms height into min-height
  • Get contact's mobile, work and home number in a string
  • Failure to delete entire contact using ContentProviderOperation
  • Fetching Contact detail Take A lot of time in android?
  • Error casting Object[] to ContentValues[]
  • Delete contact from android contacts
  • Clear chrome browser history programmatically
  • “stack level too deep” When Processing Carrierwave Image Versions in Nested Form
  • Android CalendarContract, deleting a recurring event causes all events to disappear on calendar?
  • Storing WCF rest request data with SQL Server stored procedure
  • How to force refresh on CallLog.Calls.CACHED_NAME column?
  • How to clip image to ellipse in XAML
  • Retrieving a contacts notes
  • Installing apk from within application in android
  • How to merge two Request in Laravel
  • How to set download location via chrome api
  • Unique SMS sender id?
  • Retrieve Facebook Account Information in ios 6
  • Send data from edittext to listview
  • How can go in last activity with resume button?
  • Android application: how to use the camera and grab the image bytes?
  • Dialing with Intent.ACTION_CALL stopps at # in phone number