Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need a receiver definition for each type in your manifest file like:</p> <pre><code> &lt;receiver android:name=".MyWidget" android:label="@string/medium_widget_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/medium_widget_provider" /&gt; &lt;/receiver&gt; &lt;receiver android:name=".MyWidget" android:label="@string/large_widget_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/large_widget_provider" /&gt; &lt;/receiver&gt; </code></pre> <p>This would allow you to have the same <code>AppWidgetProvider</code> class be used for multiple widgets, with different widget names and different sizes defined in the <code>&lt;appwidget-provider&gt;</code> XML.</p> <p>Now if you need more differences in your widgets than what is in the <code>&lt;appwidget-provider&gt;</code> XML I would create a base widget class that implements all the common behavoir between the different types:</p> <pre><code>public abstract class MyBaseWidget extends AppWidgetProvider </code></pre> <p>And then each of your concrete implementations could extend MyBaseWidget. Then in your manifest file you would have a receiver definition for each of your concrete implementations like:</p> <pre><code> &lt;receiver android:name=".MyMediumWidget" android:label="@string/medium_widget_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/medium_widget_provider" /&gt; &lt;/receiver&gt; &lt;receiver android:name=".MyLargeWidget" android:label="@string/large_widget_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/large_widget_provider" /&gt; &lt;/receiver&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload