Note that there are some explanatory texts on larger screens.

plurals
  1. POsetOnClickPendingIntent in widget doesn't work
    primarykey
    data
    text
    <p>I tried a lot to change my widget view's image when i click on it but it doesn't work. It's my code:</p> <pre><code> public class myAppWidgetProvider extends AppWidgetProvider { public static String ACTION_WIDGET_REFRESH = "ActionReceiverRefresh"; //... @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this provider for (int i=0; i&lt;N; i++) { int appWidgetId = appWidgetIds[i]; Intent intent = new Intent(context, myAppWidgetProvider.class); intent.setAction(ACTION_WIDGET_REFRESH); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout); rv.setOnClickPendingIntent(R.id.imageView, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, rv); } </code></pre> <p>And in onReceive i want to receive it when i click widget's view, but it doesn't work:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); final String action = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { RemoteViews rmv = new RemoteViews(context.getPackageName(), R.layout.widget_layout); //and this change doesn't work :(( \/ rmv.setImageViewResource(R.id.imageView, R.drawable.button_power_on_small); } } </code></pre> <p>It's my android manifest receiver:</p> <pre><code>&lt;receiver android:name="myAppWidgetProvider" android:exported="false" android:icon="@drawable/button_power_off"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;action android:name="com.xxx.xxx.myAppWidgetProvider.ACTION_WIDGET_REFRESH"/&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_DELETED"/&gt; &lt;action android:name="android.media.RINGER_MODE_CHANGED"/&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info_provider" /&gt; &lt;/receiver&gt; </code></pre> <p>I will be grateful if someone suggest me some solution.</p>
    singulars
    1. This table or related slice is empty.
    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. 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