Get Unique ID of Android Device?
This question already has an answer here:
Try this :
String deviceId = Secure.getString(this.getContentResolver(),
Secure.ANDROID_ID);
Toast.makeText(this, deviceId, Toast.LENGTH_SHORT).show();
android.provider.Settings.Secure.ANDROID_ID
A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device.
Source Link : http://blog.vogella.com/2011/04/11/android-unique-identifier/
Note : The value may change if a factory reset is performed on the device.
Hope this helps.
Try this:
TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// IMEI No.
String imeiNo = TM.getDeviceId();
// IMSI No.
String imsiNo = TM.getSubscriberId();
// SIM Serial No.
String simSerialNo = TM.getSimSerialNumber();
// Android Unique ID
String androidId = Settings.Secure.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
Don't forget to add
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
to your manifest file.
尝试这个:
Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
链接地址: http://www.djcxy.com/p/24634.html
上一篇: 设备的ID?
下一篇: 获取Android设备的唯一ID?