Android Question Android Device Unique ID - Alternative to PhoneId

Schakalaka

Active Member
Licensed User
Hello.
in my app, i use the code in this tutorial:
Android Device Unique ID - Alternative to PhoneId.

it work on my huawei phone with android 8, but on my new chinese tablet with android 9, it return "unknow" and don' t log it.

maybe i miss something..

Manifest file:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)

AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="colorAccent">#AAAA00</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowTranslucentNavigation">false</item>
         <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>
)
'CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
'
'CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

'CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
'
'CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'
'CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

SetApplicationAttribute(android:usesCleartextTraffic, "true")
'End of default text.

Record saved on mysql db

1591720951879.png
 

Alexander Stolte

Expert
Licensed User
you can try my class:
 
Upvote 0

Schakalaka

Active Member
Licensed User
thanks you, i'll try.
the tablet, haven t the SIM, but it can use it.. maybe this is the problem..
But B4a, find the device ID for debug..
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
What exactly do you want to achieve with this unique id?

You could generate a f.e. 64 chars long token at the very first start of the app. Of course this ID will be lost, if the user uninstalls the app or the device is lost/destroyed but then your have other options as you store the email address (like renew the token on a new device and the old token is deleted).
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've added a message in the tutorial about it being irrelevant now.
 
Upvote 0
Top