简体   繁体   English

操作系统和主屏幕可以随意更新android应用程序小部件吗?

[英]Can os and Home screen update the android app widget at will?

I want to make and app with widget to present some data,and i want to be sure it will not become a battery drain source and add all the checks i have to,so there is no problem. 我想制作一个带有小部件的应用程序以显示一些数据,并且我想确保它不会成为电池消耗的来源并添加我必须执行的所有检查,因此没有问题。

So android documentation actually says that ACTION_APPWIDGET_UPDATE 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. 因此,Android文档实际上说,可以响应于实例化此AppWidget提供程序的新实例,请求的更新间隔已过或系统启动来发送ACTION_APPWIDGET_UPDATE。

But i came into this bizarre answer here 但是我在这里遇到了这个奇怪的答案

Android widget update called twice after device boot 设备启动后,两次调用Android小部件更新

that suggest that the home screen can actually update your widget n times at will.Seems bizarre,and i cant find something similar,do i really have no control over this? 这表明主屏幕实际上可以随意更新n次窗口小部件。看起来很奇怪,我找不到类似的东西,我真的对此无能为力吗?

As in the previous answer you found, there is no way to limit how many times the home screen might update the widget - it is responsibility of the homescreen and you cannot control this. 如您在上一个答案中找到的那样,无法限制主屏幕更新小部件的次数-这是主屏幕的责任,您无法控制它。

You could add a limit in your update implementation instead. 您可以在更新实现中添加限制。 For example, record the time the checks are made. 例如,记录进行检查的时间。 If the widget update is requested again too soon after the last one, ignore it until the required amount of time passes. 如果在最后一次更新之后再次请求更新小部件,请忽略它,直到经过所需的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM