B4J Question NativeObject Type Doesn't Exist

Squiffy

Active Member
Licensed User
Longtime User
Hi - I'm trying to do this (following another thread to create UUIDs) :

Dim no As NativeObject
Return no.Initialize("NSUUID").RunMethod("UUID", Null).RunMethod("UUIDString", Null).AsString

but it complains that there is no NativeObject type. Should there be in B4j? I've tried adding all of the libraries in the manager but it doesn't seem to exist.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Try using a JavaObject (LIbrary JavaObject)

#Example Sub to retrieve a type 4 (pseudo randomly generated) UUID.
B4X:
Sub UUID As String
   Dim joUUID As JavaObject
   Return joUUID.InitializeStatic("java.util.UUID").RunMethod("randomUUID", Null)
End Sub

Output:
Log("UUID: " & UUID)
UUID: 59ec389c-6ba2-46fb-bd6b-e33b5a24ce74
 
Upvote 0
Top