Android Question Device Id Reurns unknown or blank or 0

carloz

Member
Licensed User
Longtime User
Hello Everyone,

I am using the following procedure to get device id on customer devices... It works 95% of the time, but a few people have reported that the device id is "unknown" "blank" or "0" sometimes.
Funnily, the same people on the same devices are able to retrive the device id once they restart the app.

B4X:
Sub GetDeviceId As String
Dim ph As Phone
Dim id As String
Dim r As Reflector
Dim Api As Int

   Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
   If Api < 9 Then
      'Old device
      id= ph.GetSettings("android_id")
   Else
      'New device
      id= r.GetStaticField("android.os.Build", "SERIAL")
      If id.ToLowerCase = "unknown" Then id= ph.GetSettings("android_id")
   End If
   Return id
End Sub

Has anyone else faced this issue? Any suggestions?

regards
carloz
 

carloz

Member
Licensed User
Longtime User
thnx for replying Erel.. hope you are doing great !!

:( that puts me in a bit of a fix ..
I have the app being used by 1k people , all who have registered a year back and thier ids are stored in the database, and used to validate their departments and vertical..
if i change the method, the ids would change and users wont be able to use the app without having to reregister...
is this specific to android 6 devices only? any other way around it?

regards
carloz
 
Upvote 0
Top