I am creating an Android application that sets alarms based on the String date of a list of Objects (PendingIntents, with each taking in an id, that is an integer). In order to cancel the PendingIntent, I must know the PendingIntent's id.
I am having trouble of figuring out a way to generate a unique id reliably with a minimal chance of collisions. If I simply convert the String date to miliseconds, I believe that would not be reliable since the user can change timezones on their phone and the computer can make timestamp computations that are off by a few miliseconds.
randomUUID
method - stackoverflow.com/questions/2982748/create-a-guid-in-java/… – Ben Cottrell Mar 18 at 23:15uptimeMillis()
or one of the other monotonic clocks. They won't go backwards except on reboot, and I'm pretty sure PendingIntents don't survive reboot. – Jerry101 Mar 27 at 3:29