• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

How to Get Device Phone Number

D

deus49

Guest
Hi, how do I find the device phone number? Something like device_get_phone number; returns +15059...?

I know its possible to find the phone number because there are paid extensions in the Marketplace that make calls and send sms.

Thanks
 
P

PlayLight

Guest
Hi, how do I find the device phone number? Something like device_get_phone number; returns +15059...?

I know its possible to find the phone number because there are paid extensions in the Marketplace that make calls and send sms.

Thanks
You can try to retrieve it via an extension using the TelephonyManager class (requires android.permission.READ_PHONE_STATE), but there is really no guarantee that it will return the correct value. (dependent on SIM & network provider settings)
Conbeef is right, just as easy to prompt the user and give them the option to provide a phone number or not.

You'll find that all alternative SMS apps have a similar default prompt if it can not be retrieved or referenced from the SharedPreference key-value.
 
D

deus49

Guest
You can try to retrieve it via an extension using the TelephonyManager class (requires android.permission.READ_PHONE_STATE), but there is really no guarantee that it will return the correct value. (dependent on SIM & network provider settings)
Conbeef is right, just as easy to prompt the user and give them the option to provide a phone number or not.

You'll find that all alternative SMS apps have a similar default prompt if it can not be retrieved or referenced from the SharedPreference key-value.
I have tried a GM extension in the marketplace that shows the sender phone number to the message recipient. No problem with obtaining intended receiver phone number since you need to know who you are sending message to. Extensions need send_sms_permission and worked fine when I tested it.
But I really need to know how to obtain sender phone number automatically. I have seen it in GM extension, was only wondering how it is actually done.

I will check the link you provided. Thank you.
 
P

PlayLight

Guest
No worries ;), just make sure to add a fall-back prompt anyway for the instances where this will not be available autonomously,
Otherwise users with these circumstances wont be able to use the feature/application.
 
Top