Widget onUpdate called when Configuration Activity is launched
Providing an answer after digging into the source code:
1) This is expected behavior see here
This method is also called when the user adds the App Widget
2) Seems you have found your own answer. For others looking for the docs go here
Note: Updates requested with updatePeriodMillis will not be delivered more than once every 30 minutes
3) Since the AppWidgetProvider
extends BroadcastReceiver
but is not declared final you can add the action from your second receiver
<receiver android:name="MyWidgetProvider" android:exported="true"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="org.test.mywidget.FORCE_SMALL_WIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/my_widget_info" /> </receiver>
then you can override onReceive in your MyWidgetProvider
class and if the action is your custom action handle it, otherwise call to the super.onRecieve(Context context, Intent intent) like so:
@Overridepublic void onReceive(Context context, Intent intent) { if(intent.getAction() .equals("org.test.mywidget.FORCE_SMALL_WIDGET_UPDATE")){ // handle your action } else { super.onRecieve(context, intent); }}
as per the Guide:
AppWidgetProvider is just a convenience class. If you would like to receive the App Widget broadcasts directly, you can implement your own BroadcastReceiver or override the onReceive(Context, Intent) callback.
One thing to note with this, the update to the remote view will only be called at the updatePeriodMillis, regardless of you adding your own action to the Intent for the provider to handle.
Good Luck and Happy Coding!