M Hassen
M Hassen

Reputation: 363

How to schedule a task to be executed in the future even the phone is switched off

I need to schedule a task (e.g. Send email or switch the phone off) to be executed in some date and time in the future (e.g. June 12 2013 at 3:00PM)

I want them multiple tasks, different timing, persistent even the phone is switched off.

I have searched but the results are sorta confusing. Can any one please guide me to the solution ?

Upvotes: 0

Views: 787

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

I need to schedule a task (e.g. Send email or switch the phone off)

You do not have rights to "switch the phone off", unless you are building your own firmware.

to be executed in some date and time in the future (e.g. June 12 2013 at 3:00PM)

A year out is a bit unusual.

I want... persistent even the phone is switched off.

That is not possible, unless by "switched off" you mean "in sleep mode". In that case, tactically, use AlarmManager, with a _WAKEUP-style alarm.

That being said, AlarmManager is not exactly designed for stuff a year in the future. You may want to just schedule events for the next week's worth of stuff, including an event to have you schedule the next week's worth of events.

And, if the phone is truly switched off (i.e., "Power Off" after long-pressing the POWER button), your alarms do not go off, and you will need to reschedule them when the device is turned back on.

Upvotes: 2

Related Questions