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

后端 未结 2 377
终归单人心
终归单人心 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条回答
  •  旧时难觅i
    2020-12-15 12:03

    You can try:

    TelephonyManager phoneManager = (TelephonyManager) 
        getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
    String phoneNumber = phoneManager.getLine1Number();
    

    Needs READ_PHONE_STATE permission.

提交回复
热议问题