tags:

views:

1812

answers:

2

Is there a way to get the phone that is running my app's number within the app?

Thanks,
Josh

+4  A: 
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
  mPhoneNumber = tMgr.getLine1Number();
Alex Volovoy
Requires permission READ_PHONE_STATE, but otherwise perfect
jkap
Actually, not so perfect. Last time I tried this method, it reported the phone number that my phone originally had, before my old mobile number was ported over to it. It probably still does, as the Settings app still shows that defunct number. Also, there are reports that some SIMs cause this method to return `null`. That being said, I'm not aware of a better answer.
CommonsWare
Mark is right. If the intent to use something that uniquely identifies phone i'd use getDeviceId() which will return IMEA for GSM.
Alex Volovoy
A: 

what is the solution this problem..

some project solve this problem sending sms some where then take sms number but this is not solution for me

ummani