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();
精彩评论