Hi, I would like to use UUIDs as entry IDs of data being stored in a TinyDB namespace.
I know that the free UUID generator extension stopped working a few Android versions ago; so my question is about how possible it might be to create my own extension with some java/javascript ~ just to generate a UUID from a block that requests a method of the java.util.UUID class?
I would need to learn how to create an extension of course, but first want to know if the idea is feasible - or am I leading myself down a blind alley!?
Thanks,
C
Which extension are you referring to ?
This still works OK:
I have also created a version that doesn't include the -
or the _
How about:

(draggable)
UID_generator.aia (2.0 KB)
Is randomness enough, or do you need the result to fit
https://www.baeldung.com/java-uuid
?
Thanks TIM and ABG for your help, but what I'm hoping for are standard format android-produced 32digit hex Uuid's.
TIM, do you have the time to look into building a similar app to Generate-UID that utilises java.util.UUID ?
A bing search brings up the following code - but how to turn that into an extension like Generate-UID is beyond me at present :-
(I'd be prepared to pay a sensible sum/donate to RNLI for something that meets the standards - Random Variant - described in ABG's baeldung link https://www.baeldung.com/java-uuid)
import java.util.UUID;
public class Main {
public static void main(String[ ] args) {
UUID uuid = UUID.randomUUID();
System.out.println("Generated UUID: " + uuid.toString());
}
}
C.
Here is a basic one, using randomUUID
If you feel the urge, make a donation to the RNLI, I don't need your cash, but they do
Wow, that was fast! Thanks. *[Is there an app/sys setting I need on my tablet to allow AI Companion to use/download the /classes.jar file? Got the following error on the mobile device using Companion...]
*Forget that... 2nd attempt worked perfectly! Fantastic!!
Thanks so much - big donation to RNLI coming up.
C.
but if you want the source code ?
Or is the extension not importing for you? Working fine here with companion app (Do you have the latest version 276/276u ?)
Here's a (draggable) block-only version for a UUID v4 generator if performance isn't a huge issue:
Also useful because it works on iOS where extensions are not allowed.
Had a second 'Companion' attempt and it worked brilliantly.
Many thanks. ££ -> RNLI to the Rescue!
C.
And a javascript version (so run in a Webviewer) of the Firebase based
UID code
generatePushID=function(){
var r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",e=0,t=[];
return function(){var o=(new Date).getTime(),n=o===e;e=o;for(var a=new Array(8),h=7;h>=0;h--)a[h]=r.charAt(o%64),o=Math.floor(o/64);
if(0!==o)throw new Error("convert entire timestamp");
var f=a.join("");if(n){for(h=11;h>=0&&63===t[h];h--)t[h]=0;t[h]++}else for(h=0;h<12;h++)t[h]=Math.floor(64*Math.random());
for(h=0;h<12;h++)f+=r.charAt(t[h]);
return f}}();
function getUID() {
for(var newID,success=!1;!success;)20==(newID=generatePushID()).length&&(newID,success=!0);
return newID;
}