Android Question Is it Ok to use Phone.GetSettings("android_id")

Alex_197

Active Member
Licensed User
Hi all.

Is it safe to use a code like this to get unique phone id? It works on my Android 10 phone today. But what about tomorrow? Or Advertising ID is a only safe way?

GenerateID:
Sub GenerateID() As String
   
    Try
        Dim P As Phone
        Dim IDAndroid As String=P.GetSettings("android_id")
        Log("IDAndroid=" & IDAndroid)
        Return IDAndroid
   
    Catch
        Log("GenerateID " & LastException)      
        Return "Error"
    End Try
   
End Sub
Thanks.
 

JohnC

Well-Known Member
Licensed User
Erel suggests to use the advertising ID or generate a random number when the app starts for the first time:

 

Alex_197

Active Member
Licensed User
It can actually be useful in some cases. Read more here: https://android-developers.googleblog.com/2017/04/changes-to-device-identifiers-in.html
(I wasn't aware to this in the past)

It is not a device / global id but it can be used in your app and it isn't reset when the app is uninstalled and later installed again.
Thank you, Erel.

So if the user just updates his app with new version (let say developer has made a few changes) via Google Play AdvertisingID won't change? Am I correct?
 
Top