title: Intent.putExtra works with EXTRA_APPWIDGET_IDS but not with EXTRA_APPWIDGET_ID
body: <p>Following is the code snippet of the relevant portions of my <strong>AppWidgetProvider</strong> class.</p>
  
  <pre><code>public class LargeWidgetProvider extends AppWidgetProvider {
  
      @Override
      public void onEnabled(Context context) {
          ...
      }
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int... appWidgetIds) {
          super.onUpdate(context, appWidgetManager, appWidgetIds);
          Log.i("Trigger2" , "Large Widget");
          for (int appWidgetId : appWidgetIds) {
              RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                      R.layout.widget_large);
  
              preLoadWeather(context , remoteViews);
              Intent intent = new Intent(context, LargeWidgetProvider.class);
              intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
              intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
              PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                      0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
              remoteViews.setOnClickPendingIntent(R.id.widget_button_refresh, pendingIntent);
  
              Intent intentStartActivity = new Intent(context, WeatherActivity.class);
              PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, intentStartActivity, 0);
              remoteViews.setOnClickPendingIntent(R.id.widget_root, pendingIntent2);
  
              appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
          }
          LargeWidgetService.enqueueWork(context , new Intent(context, LargeWidgetService.class));
      }
  
      @Override
      public void onDisabled(Context context) {
          ...
      }
  
      private void preLoadWeather(Context context, RemoteViews remoteViews) {
          ...
      }
  
      private String format(String rs) {
          ...
      }
  
      public void updateAppWidget(Context context , AppWidgetManager appWidgetManager , int appWidgetId , String city) {
          Log.i("Trigger2" , "Large Widget");
          AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
          ComponentName widgetComponent = new ComponentName(context, LargeWidgetProvider.class);
          int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
          RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                  R.layout.widget_large);
  
          preLoadWeather(context , remoteViews);
          Intent intent = new Intent(context, LargeWidgetProvider.class);
          intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
          intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                  0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
          remoteViews.setOnClickPendingIntent(R.id.widget_button_refresh, pendingIntent);
  
          Intent intentStartActivity = new Intent(context, WeatherActivity.class);
          PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, intentStartActivity, 0);
          remoteViews.setOnClickPendingIntent(R.id.widget_root, pendingIntent2);
  
          appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
          LargeWidgetService.enqueueWork(context , new Intent(context, LargeWidgetService.class));
      }
  }
  </code></pre>
  
  <p>Here is my code of <strong>LargeWidgetService</strong></p>
  
  <pre><code>public class LargeWidgetService extends JobIntentService {
  
      private static final String TAG = "LargeWidgetService";
  
      public static void enqueueWork(Context context , Intent intent) {
          enqueueWork(context , LargeWidgetService.class, 0x01 , intent);
      }
  
      @Override
      protected void onHandleWork(@NonNull Intent intent) {
          ...
  
          AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
          ComponentName widgetComponent = new ComponentName(this, LargeWidgetProvider.class);
          int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
  
          for (int appWidgetId : widgetIds) {
              try {
                  WeatherInfo weatherRaw = new Request(this).getItems(new WidgetPrefs(appWidgetId , this).getCity(), units);
                  lwPrefs.saveWeather(weatherRaw);
                  updateWidget(weatherRaw);
              } catch (IOException e) {
                  ...
              }
          }
      }
  
      private void updateWidget(WeatherInfo weather) {
          AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
          ComponentName widgetComponent = new ComponentName(this, LargeWidgetProvider.class);
  
          int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
          for (int appWidgetId : widgetIds) {
              ...
              RemoteViews remoteViews = new RemoteViews(this.getPackageName(),
                      R.layout.widget_large);
              ...
              widgetManager.updateAppWidget(appWidgetId, remoteViews);
          }
      }
  }
  </code></pre>
  
  <p>PS. <code>updateAppWidget()</code> in the <code>LargeWidgetProvider</code> is called only when I attach a configActivity to the widget's xml. That activity is as follows:</p>
  
  <pre><code>public class LargeWidgetConfigActivity extends AppCompatActivity {
      int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setResult(RESULT_CANCELED);
          findViewById(android.R.id.content).setBackgroundColor(ContextCompat.getColor(this , R.color.primary));
  
          final Context context = this;
  
          Intent intent = getIntent();
          Bundle extras = intent.getExtras();
          if (extras != null) {
              mAppWidgetId = extras.getInt(
                      AppWidgetManager.EXTRA_APPWIDGET_ID,
                      AppWidgetManager.INVALID_APPWIDGET_ID);
          }
  
          // If they gave us an intent without the widget id, just bail.
          if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
              finish();
          }
  
          new MaterialDialog.Builder(this)
                  .title(getString(R.string.pref_delete_cities_title))
                  .content(getString(R.string.pref_delete_cities_summary))
                  .positiveText(getString(android.R.string.ok))
                  .negativeText(getString(android.R.string.cancel))
                  .items(new DBHelper(this).getCities())
                  .itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() {
                      @Override
                      public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
                          new WidgetPrefs(mAppWidgetId , context).setCity(text.toString());
                          AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
                          new LargeWidgetProvider().updateAppWidget(context, appWidgetManager, mAppWidgetId , text.toString());
  
                          Intent resultValue = new Intent();
                          resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
                          setResult(RESULT_OK, resultValue);
  
                          finish();
                          return true;
                      }
                  })
                  .show();
      }
  }
  </code></pre>
  
  <ol>
  <li><p>In the <code>onUpdate()</code> function inside the for loop, I have a line <code>intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);</code> . So whenever I click on <code>R.id.widget_button_refresh</code> in my widget, it updates all of my widgets (Code works) . The moment I change that line to <code>intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);</code> , the refresh button stops working. Any clue on how do I resolve this? (This has no relation to the Config Activity)</p></li>
  <li><p>If I use the code inside the LargeWidgetProvider's <code>updateAppWidget()</code>, the button stops working. The moment I comment all the code inside that function, the refresh button starts working again. Any Idea on how to resolve this?</p></li>
  </ol>