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

Status
Not open for further replies.

Alex_197

Well-Known Member
Licensed User
Longtime 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

Expert
Licensed User
Longtime User
Erel suggests to use the advertising ID or generate a random number when the app starts for the first time:

 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime 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?
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Is there an adb command that return same result as Phone.GetSettings ("android_id")?
"adb shell settings get secure android_id" is different that previouse code result.
"adb shell getprop ro.serialno" is also something else.
 
Upvote 0
Status
Not open for further replies.
Top