Programmatically obtain the phone number of the Android phone

后端 未结 18 2088
南笙
南笙 2020-11-21 06:17

How can I programmatically get the phone number of the device that is running my android app?

18条回答
  •  佛祖请我去吃肉
    2020-11-21 06:32

    Just want to add a bit here to above explanations in the above answers. Which will save time for others as well.

    In my case this method didn't returned any mobile number, an empty string was returned. It was due to the case that I had ported my number on the new sim. So if I go into the Settings>About Phone>Status>My Phone Number it shows me "Unknown".

提交回复
热议问题