gpt4 book ai didi

Android AppWidget onUpdate 开机

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:32:54 25 4
gpt4 key购买 nike

启动时是否调用了 onUpdate AppWidget?

我在 onUpdate 中设置了一个警报,我想知道 onUpdate 是否会在启动时被调用,或者我应该使用 BOOT_COMPLETED Intent 。

谢谢。

最佳答案

我没有在文档中找到与此相关的任何内容,所以我只是对其进行了测试。我在我的小部件的 onUpdate() 方法中设置了一个 Toast,以查看它何时被触发。重启设备后它得到触发,所以我假设你不需要使用 BOOT_COMPLETED Intent ,但有时你不能确定足够(没有什么反对继续使用它)。

编辑:

onUpdate() 确实会在启动时被调用,Android 文档确实涵盖了这一点:

onUpdate()

Called in response to the ACTION_APPWIDGET_UPDATE and ACTION_APPWIDGET_RESTORED broadcasts when this AppWidget provider is being asked to provide RemoteViews for a set of AppWidgets. Override this method to implement your own AppWidget functionality.

Source

ACTION_APPWIDGET_UPDATE

This may be sent in response to a new instance for this AppWidget provider having been instantiated, the requested update interval having lapsed, or the system booting.

Source

关于Android AppWidget onUpdate 开机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14788965/

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