1

I have a textBox(EditText1) in android (Vs-2.3.3)

I want to show my own mobile number (provided my sim is not changed) into the text box.

Is That possible?

Please give the source code if that possible.

Please also tell me what are the prerequisites if possible.

Note : I want to show my own mobile number only , not from contacts.

divaNilisha
  • 703
  • 2
  • 11
  • 18
  • what you want to display your contact detail? – vnshetty May 04 '12 at 04:22
  • http://developer.android.com/reference/android/telephony/TelephonyManager.html#getLine1Number() – L7ColWinters May 04 '12 at 04:24
  • Hello, StackOverflow isn't really a "give me teh codez" kind of site. Please actually try some code first, then come back and ask questions. Read [ask]. If you have tried coding something, then post it along with any errors you are receiving. – Jack May 04 '12 at 04:25
  • http://stackoverflow.com/questions/2206596/how-to-get-the-mobile-number-in-real-device – dira May 04 '12 at 04:29
  • possible duplicate of [Get Phone Number in Android SDK](http://stackoverflow.com/questions/2480288/get-phone-number-in-android-sdk) – COD3BOY May 04 '12 at 04:29

2 Answers2

0
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();
Krishnakant Dalal
  • 3,568
  • 7
  • 34
  • 62
0

use TelephonyManager for getting your own mobile number as:

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String strmobinum= tm.getLine1Number();
edttxt.setText(strmobinum);

AndroidManifest.xml:

<uses-permission android:name= "android.permission.READ_PHONE_STATE"/>
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213