开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜