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
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…