Reading device phone number throws NULLPointerException

后端 未结 5 1874
时光取名叫无心
时光取名叫无心 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:33

    In order to get the phone number from the device , first you have to set your own phone number on the device, just go through :

    Settings -> About Phone -> Status -> My phone Number

    When you call this code:

    MyPhoneNumber = tMgr.getLine1Number();
    

    It's the stored number is actually returning.

提交回复
热议问题