How to find the phone number in android?

Put your problem here if it does not fit any of the other categories.

How to find the phone number in android?

Postby aptgopal » Tue Feb 08, 2011 10:51 pm

Hi
Any one help me to do this .I want to find the mobile number using in the particular android mobile programmatically

I tried the following
TelephonyManager tMgr =(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
It is working fine in Emulator but It is not working in my phone

How to do that

Thanks in advance
aptgopal
Developer
Developer
 
Posts: 25
Joined: Tue Nov 16, 2010 7:08 pm
Location: India

Top

Re: How to find the phone number in android?

Postby strider2023 » Wed Feb 23, 2011 12:49 pm

Hi,

Please check your logcat to check for any anomalies. I think that will give you an idea of what might go wrong.
strider2023
Senior Developer
Senior Developer
 
Posts: 126
Joined: Tue Mar 02, 2010 6:34 am
Location: Chennai, India

Re: How to find the phone number in android?

Postby aj87uk » Thu Mar 03, 2011 10:35 am

Unfortunately SIM cards do not always know the phone number because this is dynamic and assigned by the network.

For example in the UK my Orange network SIM will return its number from "telephonyMgr.getLine1Number()" but an O2 network SIM will return null.

I wish this were a standard feature, this would save a lot of hassle. Identifying a SIM card by IMSI "telephonyMgr.getSubscriberId()" is the only reliable way.
aj87uk
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 03, 2011 10:27 am

Re: How to find the phone number in android?

Postby strider2023 » Thu Mar 03, 2011 4:54 pm

Hi aj87uk,

Thanx for sharing your knowledge. Even I was not aware of that.
strider2023
Senior Developer
Senior Developer
 
Posts: 126
Joined: Tue Mar 02, 2010 6:34 am
Location: Chennai, India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests