Programmatically obtain the phone number of the Android phone

后端 未结 18 1987
南笙
南笙 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:55

    This is a more simplified answer:

    public String getMyPhoneNumber()
    {
        return ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
                .getLine1Number();
    }
    

提交回复
热议问题