Does Android wake from deep sleep in order to broadcast ACTION_TIME_TICK
? From experimenting, I don't think it does, but I'm looking for a definitive answer.
My experiment involved registering a simple BroadcastReceiver
to update a TextView
on receive:
registerReceiver(new BroadcastReceiver() {
int ctr = 0;
@Override
public void onReceive(Context context, Intent intent) {
testView.setText("Time ticks: " + ++ctr);
}
}, new IntentFilter(Intent.ACTION_TIME_TICK));
At 4 ticks, I turned off the screen for about 5 minutes, then turned it back on, and it read 6 ticks. At 13 ticks, I turned the screen for 10 minutes, then turned it back on, and the number of ticks read 14. It only seems to increase by 1-2 ticks no matter how long I leave the phone off, which is why I suspect it doesn't broadcast the action during deep sleep.
I looked into the Android code. No this broadcast will not wake up the phone. It uses an AlarmManager.RTC
type Alarm
to broadcast time change.
Why do you need to be notified literally every minute?
How about setting up your own Alarm using the AlarmManager.RTC_WAKEUP
type?
WARNING: Doing it every minute is will drain your battery. I suggest doing it less often, like every hour.
Please let me know if this is helpful.
Emmanuel
A better experiment: Instead of updating a TextView
which you cannot see when the phone is off, write to the Log with:
Log.v("Tick","Total ticks: " + ++ctr);
You can keep an eye on this in Logcat while your phone is asleep.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With