开发者

Why its my widget updating on the configuration activity creation?

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 =/


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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜