Is there a way such that the smart phone application will be able to fetch mobile number that is currently active in it. Is it something feasible?
Asked
Active
Viewed 1,105 times
0
-
On iOS this information is available. – rckoenes Feb 18 '13 at 10:25
-
check this link for iPhone http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-iphone-os – Monish Bansal Feb 18 '13 at 10:58
1 Answers
1
You can use the TelephonyManager
to do this:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String number = tm.getLine1Number();
You'll need to give your application permission to make this query by adding the following to your Manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
(You shouldn't use TelephonyManager.getDefault()
to get the TelephonyManager
as that is a private undocumented API call and may change in future.)

Ram kiran Pachigolla
- 20,897
- 15
- 57
- 78