我正在使用eclipse开发一个Android应用程序。我需要获取用户的唯一设备ID,以便他们可以在应用程序上提供他们的意见,但我不知道如何......如果有人能告诉我如何获取Android设备ID,我真的很感激! / p>
答案 0 :(得分:0)
查看android.provider.Secure.Settings中的常量ANDROID_ID。
http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID
Android手机上有三种类型的标识符。
IMEI
IMSI
String ts = Context.TELEPHONY_SERVICE; TelephonyManager mTelephonyMgr =(TelephonyManager)getSystemService(ts); String imsi = mTelephonyMgr.getSubscriberId(); String imei = mTelephonyMgr.getDeviceId();
Android ID这是一个64位的十六进制字符串,它是在...上生成的 设备的第一次启动。一般来说,除非是工厂,否则不会更改 复位。
Secure.getString(getContentResolver(),Secure.ANDROID_ID);
答案 1 :(得分:0)
使用以下行
import android.provider.Settings.Secure;
String android_id = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
答案 2 :(得分:0)
试试这段代码:
Will return the MDN or MEID of the device depending on which radio the
phone uses (GSM or CDMA). Each device MUST return a unique value here
(assuming it's a phone). This should work for any Android device with a
sim slot or CDMA radio. Requires READ_PHONE_STATE permission
public static String getDeviceUID(Context context) {
TelephonyManager tManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return tManager.getDeviceId();
}
The Android ID (a unique 64-bit value) as a hex string. Identical to that
obtained by calling GoogleLoginService.getAndroidId(); it is also placed
here so you can get it without binding to a service.
public static String getAndroidID(Context context) {
return Settings.System.getString(context.getContentResolver(),
Settings.Secure.ANDROID_ID);
}