Reputation: 9419
I have a problem regarding AppWidgetProvider
. When the phone starts up the onUpdate()
method for the AppWidgetProvider
gets called four times in a row, all containing the same appWidgetId
. I can't figure out why it's happening. Does anyone have a clue?
I got two types of super classes
, Main
and MainScroll
, and four classes(widgets)
that extends the
super classes
.
Example widget
public class WidgetMedium extends Main {
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
}
The manifest
<receiver android:name=".activity.Main">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
</receiver>
<receiver android:name=".activity.MainScroll">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
</receiver>
<receiver android:name=".activity.WidgetMedium"
android:label="Swedroid Widget 4x3"
android:icon="@drawable/widget_application">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_medium" />
</receiver>
<receiver android:name=".activity.WidgetScrollMedium"
android:label="Swedroid Widget 4x3 Scroll"
android:icon="@drawable/widget_application">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_scroll_provider_medium" />
</receiver>
<receiver android:name=".activity.WidgetLarge"
android:label="Swedroid Widget 4x4"
android:icon="@drawable/widget_application">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
</receiver>
<receiver android:name="com.swedroid.widget.activity.WidgetScrollLarge"
android:label="Swedroid Widget 4x4 Scroll"
android:icon="@drawable/widget_application">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_scroll_provider_large" />
</receiver>
Upvotes: 3
Views: 1596
Reputation: 3297
If Main
and MainScroll
classes are only super classes I thing they shouldn't be AppWidgetProviders
but rather abstract
classes, therefore, the receiver
definitions are not needed for them in the Manifest.
Also I think the intent-filter
below is not needed for the other four reciever
definitions.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Upvotes: 1
Reputation: 20936
I think that all four receivers in your case are active and they all receive the same intent to update your widget. Could you please add the code where you create update intent in your application?
Upvotes: 0