gpt4 book ai didi

android - 如果屏幕关闭,如何更新时钟小部件?

转载 作者:行者123 更新时间:2023-11-30 02:43:44 32 4
gpt4 key购买 nike

我使用了本教程 http://forum.xda-developers.com/showthread.php?t=1732939创建一个简单的时钟小部件。

遗憾的是它运行得不是很好。当屏幕关闭时,小部件将不再更新,因此不会显示正确的时间。

那么,如何在关闭屏幕的情况下更新小部件?

最佳答案

看看重复警报:

They operate outside of your application, so you can use them to trigger events or actions even when your app is not running, and even if the device itself is asleep.

https://developer.android.com/training/scheduling/alarms.html

或者在“WakeLock”:

One legitimate case for using a wake lock might be a background service that needs to grab a wake lock to keep the CPU running to do work while the screen is off. Again, though, this practice should be minimized because of its impact on battery life.

https://developer.android.com/training/scheduling/wakelock.html#cpu

使用第一种方法可以帮助您理解您的观点。

关于android - 如果屏幕关闭,如何更新时钟小部件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25392634/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com