I have implemented a NotificationListenerService that runs in the background.
From this services onNotificationPosted method, I would like to be able to queue work to happen in 2 minutes time.
What is the best way to go about this?
Both JobScheduler and Workmanager have a minimum interval of 15 minutes. Because I already have a background service running, I don't think I really need to use those, correct?
Could I just use something like a TimerTask, or even a sleep in my onNotificationPosted method?
WorkManagerhas 15 minutes interval only for periodic tasks, thats is not what you want, as I can see. You can schedule task withOneTimeWorkRequestto let it be executed in 2 minutes after theonNotificationPostedmethod call.As you already have running service, you can probably just delay your task in separate coroutine scope
or use