Reputation: 135
I want to disable service at [user choice] and enable it at [user choice] for every day. What is the best way to accomplish that?
Should i use Calendar? (Calculate start and end times, or something else? )
Upvotes: 1
Views: 705
Reputation: 11800
What you looking for is called 'Cron'.
It can be achieved with the AlarmManager.
AlarmManager myAlarmManager = Context.getSystemService(Context.ALARM_SERVICE)
Upvotes: 1
Reputation: 7076
From Justin Breitfeller's answer to Android Java - Creating a Cronjob:
The Android AlarmManager is the class you are looking for. It can trigger an intent to be sent to your application at set intervals so you can run any task you would like.
Upvotes: 1