你能强制广播来更新小部件吗?
我几乎完成了我的第一个应用程序,一个电池小部件的制作,一切都运行得很好。唯一困扰我的是,我有一个广播接收器,当电池电量发生变化时,它会更新小部件,但是当我第一次将小部件添加到主屏幕时,它会等待电池电量/状态发生变化。 (插入或拔出设备也会更新它)。将意图过滤器更改为发送广播的其他方式不起作用,因为它不携带电池电量。我想知道是否有办法强制广播电池电量信息?
谢谢,菲尔。
I have almost finished making my first app, a battery widget and it all works fairly well. The only thing that is bothering me is that i have a broadcast reciver for when the battery level changes it updates the widget, but when i first add the widget to the home screen it then waits for the battery level / state to change. (plugging or uplugging the device updates it too). Changing the intent filter to other means of sending a boradcast doesn't work as it doesn't carry the battery level. I was wondering if there is a way for force a broadcast with the battery level information?
Thanks, Phil.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您正在调用
小部件提供商的 onUpdate() 方法。创建小部件后,它应该自动运行 onUpdate()
Make sure you are calling
in your onUpdate() method of your widget provider. When the widget is created it should automatically run onUpdate()