In my little app, I receive a series of queued onEventXXX(), from the system (not controlled by me).
The timing of those onEventXXX() is not guaranteed. The only thing guaranteed is that they are received in the order in which they were put into the queue.
Inside onEventXXX() I have to fire an operation (O) that cannot start while another process (P) is going on.
But I cannot just discard this "firing an operation (O)". I must wait until that process (P) is complete, then fire it.
IOW, I have to queue or at least postpone that "firing an operation" until that process (P) is complete.
My immediate idea for implementing this was that , instead of firing the operation (O), I would:
- Start a one-shot timer that would periodically check on process (P)
- When timer elapses, if process (P) isn't complete, start the time (itself) again.
- When timer elapses, if process (P) is complete, fire operation (O).
But knowing the richness of Android, I am suspecting there is a better way of doing this, already built into the system/API.
If there is a better way to implement the above, what would it be?