Android Question Get AndroidId B4X vs JAVA

netsistemas

Active Member
Licensed User
Longtime User
Another developer uses java to get the AndroidId with this statement,

CODIGO JAVA:
B4X:
androidd = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID)


while I use this other one.

B4X FUNCION (only use getsetting one time in my app, move valur to public var v_AndroidId)
B4X:
public Sub GetAndroidId() As String
    Dim p As Phone
    'tags: Perminal dispositivo
    'Terminal para la tabla TerminalesApp
    If V_AndroidId = "" Then
        V_AndroidId = P.GetSettings("android_id")
    End If
    Return V_AndroidId
End Sub


Should it return the same value?

I say this because it seems that in some cases it does not match. It seems that this number was one when I installed an application, and another at this time, which puzzles us.
 

Num3

Active Member
Licensed User
Longtime User
Yes, it is possible the id changes, because it is generated from at least 3 inputs to ensure privacy i think.

From android developer:

On Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device. Values of ANDROID_ID are scoped by signing key and user. The value may change if a factory reset is performed on the device or if an APK signing key changes. For more information about how the platform handles

Note: For apps that were installed prior to updating the device to a version of Android 8.0 (API level 26) or higher, the value of ANDROID_ID changes if the app is uninstalled and then reinstalled after the OTA. To preserve values across uninstalls after an OTA to Android 8.0 or higher, developers can use Key/Value Backup.
 
Upvote 1

netsistemas

Active Member
Licensed User
Longtime User
And what function can I use in java and b4x that returns the same id?
or will it not be possible? (i think this, beacuse aap-signing key are diferrent in one app and in other. or... umm... sign with same signkey..)
 
Upvote 0

Num3

Active Member
Licensed User
Longtime User
And what function can I use in java and b4x that returns the same id?
or will it not be possible? (i think this, beacuse aap-signing key are diferrent in one app and in other. or... umm... sign with same signkey..)

Android will not give any ID that can be tracked, you have to develop a method by yourself, take a look at the developer guidelines.
 
Upvote 0

Similar Threads

Top