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?
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?
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.
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.