简体   繁体   中英

Get unique device ID in android

I would like to know how to get a String that uniquely identify the current device in android. I know this has been asked before but all the answers are the same: to use the ANDROID_ID constant. The thing is that it is deprecated and also insecure. Is there any other possibility?

Thanks.

There is no ideal way. Best way is to generate one on your own and then reuse it till app is installed. You can use

 String uniqueId = UUID.randomUUID().toString(); 

Generate it the first time the app launches and save it in your shared preference for further use.. This will change after every new installation and hence you can track app installations as well.

See the following post which describe the several ways to retrieve an Unique ID to identify Android devices..

https://medium.com/@ssaurel/how-to-retrieve-an-unique-id-to-identify-android-devices-c40080e04fa4

and refer to Android Developers Best Practices for Unique Identifiers to know which are recommended and which are not..

https://developer.android.com/training/articles/user-data-ids.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM