保持小部件活动并响应

发布于 2024-10-17 09:38:23 字数 277 浏览 4 评论 0原文

我并不完全清楚 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终难遇 2024-10-24 09:38:24

我假设您正在谈论 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文