GUID or Unique Identifier/Key

niqpw

Member
Licensed User
Longtime User
Hi

Is there any way to generate a GUID, as is possible in VB?

I would like to create an identifier, which can be generated on a phone and must be unique (i.e. no one else would produce the same one, even on the same device), so any other suggestions would be great.

Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can do this with the Reflection library:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim key As String
    key = GetUniqueKey
End Sub

Sub GetUniqueKey
    Dim r As Reflector
    r.Target = r.RunStaticMethod("java.util.UUID", "randomUUID", Null, Null)
    Return r.RunMethod("toString")
End Sub
 
Upvote 0
Top