How to generate a unique code for each device?

Asked

Viewed 136 times

1

I need to do a draw and for that a unique code has to be generated for each device. Even uninstalling and reinstalling the app, the generated code has to be always the same.

How to solve this?

2 answers

2

You can use the IMEI of the apparatus for that reason.

The problem is that an advanced user, or a cell phone maintenance, can change the IMEI, then depends on the level of reliability required for your application, for most is enough since if the user does this, he knows it is at his 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 doesn’t use the cellular network, IMEI is not a good option.

  • Thanks for the Tips :)

1


IMEI may not be a good alternative, because some tablets do not have, and need permission from the user to access. Google has a very good article about this: http://android-developers.blogspot.com.br/2011/03/identifying-app-installations.html

A pro your case solution 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 one md5 of these ID’s.

  • Hello, does this violate any google play terms ? I’ve heard that you can’t put this if you don’t put it in terms, ?

  • I do not understand the question, but if you are talking about the access permissions to the IMEI, just put in the same manifest. But I think the biggest problem in using the IMEI are the tablets that only have wi-fi, because they do not have IMEI.

  • 1

    I think the best solution for you would be to use ANDROID_ID (Settings.Secure.ANDROID_ID), but some devices came out with this bugged ID (read the link in the post), so I think it would be best to use ANDROID_ID concatenated with Build.SERIAL. And if you want more security, you can concatenate the IMEI together.

  • Thank you, I will concatenate the 2,Thank you for your attention

Browser other questions tagged

You are not signed in. Login or sign up in order to post.