开发者

Obtaining the phone number and phone ID for a phone in android

开发者 https://www.devze.com 2023-02-22 05:49 出处:网络
everyone. I have to build an Android application and one requiremen开发者_运维问答t is to be able to record the phone number and the phone ID. Is there any to do this? Any help would be much appreciat

everyone. I have to build an Android application and one requiremen开发者_运维问答t is to be able to record the phone number and the phone ID. Is there any to do this? Any help would be much appreciated.


May be TelephonyManager.getDeviceId()


Note that you can get the telephone number, but it's usually inaccurate information (whatever the user has entered manually in the settings, if anything).

This is the code to do it:

TelephonyManager tm;
String phoneNumber = tm.getLine1Number();
String IMEI = tm.getDeviceId();


Correct code :

TelephonyManager telManager;
telManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
telManager.getDeviceId();
0

精彩评论

暂无评论...
验证码 换一张
取 消