• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Telephone number

Hello!
Please help.

My friend is making small software for his company, we find problem with detecting telehone number from his handy. How can we detect telpehone number on the handy?
 
Here is how you can do it:
Code:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();

The problem is that it requires that the phone number is stored on the SIM card - many carriers do that, but it is not guaranteed.

Required Permission:
Code:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
Here is how you can do it:
Code:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();

The problem is that it requires that the phone number is stored on the SIM card - many carriers do that, but it is not guaranteed.

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

Is this will work with two simcards?
Is this for any special device or any handy?..
 
Back
Top Bottom