Android Code Snippet [B4X] UUID generator

With this UUID generator you will not have problems with duplicates, in Java 11 or higher it generates version 4.

B4X:
Public Sub UUID As String
#If B4i
   Dim no As NativeObject
   Return no.Initialize("NSUUID").RunMethod("UUID", Null).RunMethod("UUIDString", Null).AsString
#Else
    Dim jo As JavaObject
    Return jo.InitializeStatic("java.util.UUID").RunMethod("randomUUID", Null)
#End If
End Sub

ref.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…