如何获得Android设备ID

这个问题在这里已经有了答案:

  • 是否有唯一的Android设备ID? 40个答案

  • 查看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);


  • 使用下面的行,

    import android.provider.Settings.Secure;
    
    String android_id = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    

    试试这个代码:

     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);
    }
    
    链接地址: http://www.djcxy.com/p/24651.html

    上一篇: how to get an android device ID

    下一篇: Android Unique ID