Reading device phone number throws NULLPointerException

后端 未结 5 1888
时光取名叫无心
时光取名叫无心 2020-12-21 23:48

I am trying to read the phone number of the device using the following code. When phone number is not available I read the subcriber id. It works in some phones and throws N

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 00:26

    Sometimes the phone number is not set in the phone's settings. In these cases, getLine1Number() will return null. You will need to figure out an alternate way of tracking whatever you're tracking.

    This is an issue that people run into a lot. I don't program on android much, but ive seen this get asked a lot. Make sure you use the search to check if the question you're asking has been asked before.

提交回复
热议问题