• <i id='Bsd9w'><tr id='Bsd9w'><dt id='Bsd9w'><q id='Bsd9w'><span id='Bsd9w'><b id='Bsd9w'><form id='Bsd9w'><ins id='Bsd9w'></ins><ul id='Bsd9w'></ul><sub id='Bsd9w'></sub></form><legend id='Bsd9w'></legend><bdo id='Bsd9w'><pre id='Bsd9w'><center id='Bsd9w'></center></pre></bdo></b><th id='Bsd9w'></th></span></q></dt></tr></i><div id='Bsd9w'><tfoot id='Bsd9w'></tfoot><dl id='Bsd9w'><fieldset id='Bsd9w'></fieldset></dl></div>

    <tfoot id='Bsd9w'></tfoot>
      <legend id='Bsd9w'><style id='Bsd9w'><dir id='Bsd9w'><q id='Bsd9w'></q></dir></style></legend>

        <small id='Bsd9w'></small><noframes id='Bsd9w'>

          <bdo id='Bsd9w'></bdo><ul id='Bsd9w'></ul>
      1. 如何从服务更新小部件?

        时间:2023-09-09

            <tbody id='jQLVN'></tbody>
              <bdo id='jQLVN'></bdo><ul id='jQLVN'></ul>

              • <small id='jQLVN'></small><noframes id='jQLVN'>

                <legend id='jQLVN'><style id='jQLVN'><dir id='jQLVN'><q id='jQLVN'></q></dir></style></legend><tfoot id='jQLVN'></tfoot>
                <i id='jQLVN'><tr id='jQLVN'><dt id='jQLVN'><q id='jQLVN'><span id='jQLVN'><b id='jQLVN'><form id='jQLVN'><ins id='jQLVN'></ins><ul id='jQLVN'></ul><sub id='jQLVN'></sub></form><legend id='jQLVN'></legend><bdo id='jQLVN'><pre id='jQLVN'><center id='jQLVN'></center></pre></bdo></b><th id='jQLVN'></th></span></q></dt></tr></i><div id='jQLVN'><tfoot id='jQLVN'></tfoot><dl id='jQLVN'><fieldset id='jQLVN'></fieldset></dl></div>

                • 本文介绍了如何从服务更新小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个后台服务,可以配置为每 x 分钟执行一次操作.我想实现一个小部件,每次我的服务执行该操作时都会更新.但是,我无法以任何方式调用 AppWidgetProvider 的 onUpdate 方法,除非将小部件添加到主屏幕.

                  I have a background service that can be configured to perform some action every x minutes. I want to implement a widget that gets updated every time my service performs that action. However, I can't get the onUpdate method of my AppWidgetProvider called in any way, except when adding a widget to the homescreen.

                  我尝试发送 APPWIDGET_UPDATE 意图,但 onUpdate 没有被调用,尽管 AppWidgetProvider 确实收到了意图,因为调用了 onReceive 方法.有什么方法可以从服务触发小部件更新?

                  I tried sending APPWIDGET_UPDATE intents but onUpdate did not get called although the AppWidgetProvider did receive the intent since the onReceive method was called. Is there any way I can trigger widget updates from a service?

                  推荐答案

                  只需让自己成为一个 RemoteViews 并直接在 Service 中更新小部件.您将通过以下方式获得 AppWidgetManager:

                  Just make yourself a RemoteViews and update the widget(s) directly in the Service. You'll get your AppWidgetManager via:

                  AppWidgetManager mgr=AppWidgetManager.getInstance(this);
                  

                  其他一切正常.

                  注意:-如果您真的想强制现有的 AppWidgetProvider 完成工作,请向您的组件发送带有自定义操作的广播,然后调用 onUpdate() 自己从 onReceive() 获取时.

                  Note:- If you really want to force the existing AppWidgetProvider to do the work, send a broadcast with a custom action to your component, and call onUpdate() yourself from onReceive() when you get it.

                  这篇关于如何从服务更新小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Android 自定义小部件样式:如何将它们放入命名空间? 下一篇:通过 AppWidgetManager 更新我自己的小部件时,电源控制小部件显示一小会儿,这是什么问题?

                  相关文章

                  <small id='QPGGg'></small><noframes id='QPGGg'>

                    <i id='QPGGg'><tr id='QPGGg'><dt id='QPGGg'><q id='QPGGg'><span id='QPGGg'><b id='QPGGg'><form id='QPGGg'><ins id='QPGGg'></ins><ul id='QPGGg'></ul><sub id='QPGGg'></sub></form><legend id='QPGGg'></legend><bdo id='QPGGg'><pre id='QPGGg'><center id='QPGGg'></center></pre></bdo></b><th id='QPGGg'></th></span></q></dt></tr></i><div id='QPGGg'><tfoot id='QPGGg'></tfoot><dl id='QPGGg'><fieldset id='QPGGg'></fieldset></dl></div>
                      <bdo id='QPGGg'></bdo><ul id='QPGGg'></ul>
                    <tfoot id='QPGGg'></tfoot>
                      <legend id='QPGGg'><style id='QPGGg'><dir id='QPGGg'><q id='QPGGg'></q></dir></style></legend>