保持小部件活动并响应
我并不完全清楚 widget/WidgetProvider 的生命周期,也不知道您对小部件保持活动状态的时间有什么控制权。我所说的“主动”是指能够响应事件并更新其远程视图。您如何检测它何时不再响应。我已经通过调试器运行,发现有时即使应该处理事件,它也会停止在更新、接收等中打印日志消息。单击不再传递到接收等。您如何知道以编程方式检测这些更改?我希望能够检测到小部件的更改,这些更改将导致其被卸载或以其他方式停止运行。我可能想请求 android 重新加载小部件。我如何告诉 Android 尝试重新加载小部件或消除加载小部件消息的问题?谢谢
The widget/WidgetProvider lifecycle is not entirely clear to me or what control you have over the how long the widget remains active. By Active I mean able to respond to events and update its remote views. How can you detect when it is no longer responding. I've run my thru the debugger and found that sometimes it stops printing log messages in update, receive etc even when events should be handled. The click no longer passes to receive etc. How do you know detect these changes programatically? I want to be able to detect changes to the widget which would render cause it to be unloaded, or to otherwise stop running. I might want to request that android reload the widget. How would I tell Android to try to reload the widget or get rid of the problem loading widget message? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在谈论 AppWidgetProvider?它永远不应该停止“响应”。听起来您正在通过远程视图进行一些更改,这些更改正在删除可点击视图上的待处理意图,或者您没有正确设置待处理意图或其他内容。在更新远程视图的位置发布您的代码。
您是否确实看到了“加载小部件时出现问题”消息,或者您的待处理意图在单击时似乎没有触发?
I assume you are talking about an AppWidgetProvider? It should never stop "responding". It sounds like your are making some changes via remote views that are removing the pending intents on your clickable views, or you aren't setting the pending intents properly or something. Post your code where you update the remote views.
Are you actually seeing a "problem loading widget" message, or do your pending intents just not seem to fire when clicked?