How to generate a unique code for each device?

1

I need to make a draw and for this a unique code must be generated for each device. Even uninstalling and reinstalling the app, the generated code must always be the same.

How do I fix this?

    
asked by anonymous 11.07.2016 / 02:49

2 answers

1

IMEI may not be a good alternative, as some tablets do not have, in addition to needing the user's permission to access. Google has a very good article about it: link

A solution for your case could be to concatenate some of the ID's described in the article, such as Serial (android.os.Build.SERIAL) and Android ID (Settings.Secure.ANDROID_ID), or generate a UUID from an md5 of these ID's.

    
11.07.2016 / 06:05
2

You can use your device's IMEI to do this.

The problem is that an advanced user, or a mobile maintenance, can change the IMEI, it depends on the level of reliability required for your application, most are enough since if the user does this, he knows which is at own risk. But as Emerson said in another answer, if you're also making this app for tablets or any other type of android device that does not use the cellular network, IMEI is not a good option.

    
11.07.2016 / 03:27