Device ID Giving null Value

This question already has an answer here:

  • Is there a unique Android device ID? 40 answers

  • You shouldn't really use the ANDROID_ID, you have no real guarantee that it will give you a unique identifier for the device and it is known that some older devices give the value null , or as in Moto's case, the same static value across multiple devices. This value also changes when the phone is reset to the factory default, and is super easy to change on a rooted device.

    The correct way is to generate your own UUID via.

    String uudid = UUID.randomUUID()
    

    You then save this in your App, for example through a SharedPreference . You can then use Google's Android backup storage to retain this identifier even if the user uninstalls your App.

    More information on Backup here: http://developer.android.com/guide/topics/data/backup.html

    If you don't take my word for it, you should take Reto Meier's word for it, he is a developer advocate at the Google Android team. This video will explain what I just told you, check out around minute 15, he also specifically instructs developers not to use the ANDROID_ID .

    http://www.youtube.com/watch?v=twmuBbC_oB8&list=WL86437554BC3E54B5

    链接地址: http://www.djcxy.com/p/24644.html

    上一篇: 我如何获得Android设备的唯一ID?

    下一篇: 设备ID赋予空值