Firefoxx Pwnass
Firefoxx Pwnass

Reputation: 135

Run code at specific time, every day

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

Answers (2)

JSON C11
JSON C11

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

0x6C38
0x6C38

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

Related Questions