将TIME_TICK广播深度睡眠?深度、睡眠、TIME_TICK

2023-09-07 04:56:09 作者:风继续吹

难道Android的唤醒的深度睡眠,以广播 ACTION_TIME_TICK ?从实验,我并不想这样做,但我正在寻找一个明确的答案。

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.

我的实验只涉及到注册一个简单的的BroadcastReceiver 更新的TextView 上获得:

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));

在4蜱,我关掉屏幕约5分钟,然后把它重新打开,上面写的6蜱。在13蜱,我把屏幕10分钟,然后把它重新打开,和扁虱的数量看14。这似乎只是1-2,以增加蜱不管多久,我离开了手机关机,这就是为什么我怀疑它不广播在深度睡眠的作用。

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.

推荐答案

我看着在Android code。没有这个广播也不会醒了电话。它使用了 AlarmManager.RTC 键入警报播出时间的变化。

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?

如何使用 AlarmManager.RTC_WAKEUP 键入建立自己的报警?

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.

灵光

 
精彩推荐
图片推荐