Android Question Alternative to IMEI as obtaining unique identifier

Sergio Castellari

Active Member
Licensed User
Hello,
Until Android 8 version, you could get IMEI as unique identifier. With the Android 10 version you can no longer. What can be the alternative to get a unique identifier? Greetings
 

Sergio Castellari

Active Member
Licensed User
Thanks!,
I was looking at the post (which in turn took me here https://support.google.com/googleplay/android-developer/answer/6048248?hl=en) but it seems that the end user can disable it when he decides to opt out of advertising. Meanwhile, I was thinking of a procedure that creates a random ID or it could be based on Date + Hour + Minutes + seconds in a file in an application folder (the first time) and use that ID as an alternative to IMEI. What do you think of my idea? How could it be done?
Greetings
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
B4X:
    'Get Id Device
    Dim p As Phone
    DeviceID = p.GetSettings("android_id").ToUpperCase
    Log($"DeviceID: ${DeviceID}"$)
or
or

etc. etc.

😁😁😁😁
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
If you generated a just a 16 digit decimal number (as a string, say) then with a million users there would be only a one in ten billion chance of repeating the same identifier - a pretty safe solution. If you include letters then even six characters are more than enough.

The only problem with this approach is that the user's identity is lost if they uninstall and reinstall the app.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I have tested this solution up to Android version 10.
And it is not lost if you restart or reinstall Android.
B4X:
   'Get Id Device
    Dim p As Phone
    DeviceID = p.GetSettings("android_id").ToUpperCase
    Log($"DeviceID: ${DeviceID}"$)
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
B4X:
    'Get Id Device
    Dim p As Phone
    DeviceID = p.GetSettings("android_id").ToUpperCase
    Log($"DeviceID: ${DeviceID}"$)
or
or

etc. etc.

😁😁😁😁
Mr. @oparra you are a GENIUS !!!! ... Thank you, it works both in Android 8 and 10, it returns a unique 16 character ID for the device. This was what I needed! I have no words to thank you! You are on another level !!! Are you Brazilian? Greetings

Señor @oparra usted es un GENIO!!!!...Mil gracias, funciona tanto en Android 8 como 10, me devuelve un ID de 16 caracteres unico para el dispositivo.
Esto era lo que Yo necesitaba!
No tengo palabras para agradecerle! Usted esta en otro nivel !!!
¿Usted es Brasilero?
Saludos
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
If you generated a just a 16 digit decimal number (as a string, say) then with a million users there would be only a one in ten billion chance of repeating the same identifier - a pretty safe solution. If you include letters then even six characters are more than enough.

The only problem with this approach is that the user's identity is lost if they uninstall and reinstall the app.
Hi @Brian Dean Sure, I intended to make a function to try to solve the issue, but the information from @oparra is great, it solves my concern easily and without depending on special permissions that Android refuses to grant. Kind regards!
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
Mr. Oparra es chileno¡¡
que tonto soy!!!!!...Despues me di cuenta que desde el avatar se puede saber la nacionalidad!!!!....Mil perdones @oparra ... el entusiamo me hace perder "cosas" de vista!!!
Gracias por desburrarme @José J. Aguilar ! Y de paso te pregunto?...como vas con el COVID ???
[Nota aparte: En mi caso: recien ayer me pude dar la primera dosis de la vacuna!]
 
Upvote 0
Top