title: "Couldn't add widget" when imageview clicked
body: <p>I was testing my app in a phone with android n. There was no problems with the widget in that phone. But when i tried on other phones it is making weird things when i clicked the ImageView refreshes and transfors to watch widget and then shows error message. And there is nothing in the logcat. </p>
  
  <p>public class RadioWidget extends AppWidgetProvider {</p>
  
  <pre><code>static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                              int appWidgetId) {
  
      // Construct the RemoteViews object
      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.radio_widget);
      //Go to radio/track info fragment
      Intent radiointent = new Intent(context, MainActivity.class);
      radiointent.setAction("**********.play");
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, radiointent, 0);
      views.setOnClickPendingIntent(R.id.wlastp, pendingIntent);
      radiointent.setAction("*********.track.info.last");
      pendingIntent = PendingIntent.getActivity(context , 0, radiointent, 0);
      views.setOnClickPendingIntent(R.id.artwork, pendingIntent);
      //Play/Stop radio
      Intent controls = new Intent(context, NotificationControls.class);
      controls.setAction("********.widget.play");
      PendingIntent play = PendingIntent.getBroadcast(context.getApplicationContext(),1,controls,0);
      views.setOnClickPendingIntent(R.id.wplay, play);
      controls.setAction("********.widget.stop");
      PendingIntent stop = PendingIntent.getBroadcast(context.getApplicationContext(),2,controls,0);
      views.setOnClickPendingIntent(R.id.wstop, stop);
      views.setTextViewText(R.id.trackname, "now playing"));
      //Load image
      Glide.with(context.getApplicationContext())
              .load(/* artwork url*/)
              .asBitmap()
              .error(R.mipmap.album_placeholder)
              .into(new AppWidgetTarget(context.getApplicationContext(),views,R.id.artwork,appWidgetId));
      else views.setImageViewResource(R.id.artwork, R.mipmap.album_placeholder);
      int button_state = R.drawable.ic_play_arrow_black_24dp;
      if(/* checking if radio is playing */) button_state = R.drawable.ic_pause_black_24dp;
      views.setImageViewResource(R.id.wplay, button_state);
      // Instruct the widget manager to update the widget
      appWidgetManager.updateAppWidget(appWidgetId, views);
  }
  
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      // There may be multiple widgets active, so update all of them
      for (int appWidgetId : appWidgetIds) {
          updateAppWidget(context, appWidgetManager, appWidgetId);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>xml</p>
  
  <pre><code>    &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/BG"
      android:padding="@dimen/widget_margin"&gt;
      &lt;ImageView
          android:layout_width="80dp"
          android:layout_height="match_parent"
          android:src="@mipmap/album_placeholder"
          android:contentDescription="@string/cd_artwork"
          android:id="@+id/artwork"
          android:layout_alignParentLeft="true"
          android:scaleType="centerCrop"/&gt;
  
      &lt;TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:text="@string/media_play_now"
          android:id="@+id/trackname"
          android:layout_alignParentTop="true"
          android:layout_toRightOf="@+id/artwork"
          android:layout_toEndOf="@+id/artwork"
          android:textSize="16sp"
          android:minLines="2"
          android:layout_marginTop="4dp"
          android:layout_marginLeft="16dp"
          android:layout_marginRight="16dp"/&gt;
  &lt;LinearLayout
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/trackname"
      android:layout_alignLeft="@+id/trackname"
      android:layout_alignStart="@+id/trackname"
      &gt;
      &lt;ImageView
          android:id="@+id/wplay"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_play_arrow_black_24dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginBottom="8dp"
          /&gt;
  
      &lt;ImageView
          android:id="@+id/wstop"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_stop_black_24dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginBottom="8dp"
          /&gt;
  
      &lt;ImageView
          android:id="@+id/wlastp"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_last_played_black_24dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginBottom="8dp"
          /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>manifest</p>
  
  <pre><code>&lt;receiver android:name=".RadioWidget"&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/radio_widget_info" /&gt;
          &lt;/receiver&gt;
  </code></pre>
  
  <p>and here is my method updates widget from Service</p>
  
  <pre><code>public void updateRadioWidget(Context context) {
          AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
          ComponentName widgetComponent = new ComponentName(context, RadioWidget.class);
          int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
          Intent update = new Intent();
          update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
          update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
          context.sendBroadcast(update);
      }
  </code></pre>
  
  <p>I tried the other post but no luck. It is working android N but not in others. </p>