为什么我的小部件在配置活动创建时更新?
我已将其设置为每 12 小时更新一次: android:updatePeriodMillis="43200000"
然后在清单中我有这个:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!--
*************************************************************************************************
* Provider Configure Activity
*************************************************************************************************
-->
<activity android:name=".ConfiguratorActivity"
android:label="Configure Widget"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<!--
*************************************************************************************************
* Widget Provider Receiver
*************************************************************************************************
-->
<receiver android:name=".WidgetProvider">
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<service android:name=".AppWidget$UpdateService" />
</receiver>
</application>
但是,每次我启动配置活动时创建小部件本身时,应用程序都会不断更新,但当我单击“确定”按钮时,它的方法没有更新强制小部件指令=/
i have set it to update each 12 hours :
android:updatePeriodMillis="43200000"
then in the manifest I have this:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!--
*************************************************************************************************
* Provider Configure Activity
*************************************************************************************************
-->
<activity android:name=".ConfiguratorActivity"
android:label="Configure Widget"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<!--
*************************************************************************************************
* Widget Provider Receiver
*************************************************************************************************
-->
<receiver android:name=".WidgetProvider">
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<service android:name=".AppWidget$UpdateService" />
</receiver>
</application>
however the application keep updating each time I create the widget itself when i start the configuration activity but it does not update when i click the ok button wich its the metod that have the forcing widget instructions =/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您创建小部件时,它们总是会更新,以便您可以准备正确的外观。这是一件好事;否则,您的初始布局(如 xml 中定义)将一直显示,直到 12 小时后最终刷新。如果您不需要,则必须检测这是第一次刷新(向共享首选项写入一个标志),然后忽略此刷新。
按钮:如何连接强制刷新按钮?
Widgets always get updated when you create them so that you can prepare the proper look. This is a good thing; otherwise your initial layout (as defined in the xml) would be displayed until it finally refreshes after 12 hours. If you don't need that you have to detect that it's the first refresh (write a flag to shared prefs) and then ignore this one.
Button: how did you connect the button to force a refresh?
自 Donut (Android 1.6) 以来,最低 &更新小部件的最长时间为 30 分钟,主要是为了避免您的电池很快耗尽。
Android 人员必须更改他们的文档:
https://developer.android。 com/reference/android/appwidget/AppWidgetProviderInfo.html#updatePeriodMillis
Since Donut (Android 1.6) the minimum & maximum time to update the widget is 30 min, mainly to avoid your battery will be consumed shortly.
Android guys have to change their documentation:
https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo.html#updatePeriodMillis