How to get the phone number of the phone in android code?

后端 未结 2 367
终归单人心
终归单人心 2020-12-15 11:25

I tried googling in google but unable to find the answer

Will anyone please let me know, how can i retrieve the current phone number from the android code. I think p

2条回答
  •  有刺的猬
    2020-12-15 12:01

    TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String phonenumber = tm.getLine1Number();
    

    This link may be the best collection of TelephonyManager related answers. But still it is not guaranteed that you will be returned a telephone number.

    Check this out!

提交回复
热议问题