Programmatically obtain the phone number of the Android phone

后端 未结 18 1956
南笙
南笙 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

    There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported).

    I know it is pain, but most likely the best solution is just to ask the user to enter his/her phone number once and store it.

提交回复
热议问题