本文主要是介绍独一无二的DeviceId,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
两个概念
IMSI (International Mobile Subscriber Identity) of the SIM-Card present in your mobile and the IMEI (International Mobile Equipment Identity). The IMSI identifies with the SIM, the IMEI with the device.
IMSI用来标记sim卡 而IMEI用来标记设备的
获取方法:
String myIMSI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
// emulator returns: 310995000000000
String myIMEI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMEI);
// emulatorreturns: 000000000000000
2.
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();
set <uses-permission android:name="android.permission.READ_PHONE_STATE"/> in AndroidManifest.xml.
3.String unique_id = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
4.String imei = TelephonyManager.getDefault().getDeviceId();
if (TextUtils.isEmpty(imei)) {
return "";
}
这篇关于独一无二的DeviceId的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!