独一无二的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 ""; 
}

你可能感兴趣的:(android,String,service,mobile)