Does android support real time events? If so how could they be implemented?

605 views Asked by At

I'm using Android Studio to develop and application and I'd like that when a certain moment of time is met the application performs some defined action.

I know I could create a service that continously checks for actual time, every little seconds and if it happens to be equal or bigger than the needed time it performs the action, but doing it this way looks too resource consuming.

Is there some way in Android to do something like when a defined time comes, an interruption is sent and the defined action is fired?

It would be enough with supporting a soft time event, it doesn't mind for my application for the event to be fired some seconds later.

Thanks for helping.

2

There are 2 answers

0
Basil Battikhi On

Yes take a look at AlarmManager it will let you do an action in a specific time

0
DuliNini On

If you need to check some external databases once every X seconds/minutes, then you may consider using a Handler & Runnable with postDelayed() method to achieve what you need.