title: Widget not handling click event
body: <p>i already checked all the other already solved question but no one fixed my issue. If anyone could help me it would be wonderful. Thanks in advance.</p>
  
  <p>I am using a GridView with 1 column.
  I want to open the MainActivity.class on the GridView or on an item click.
  Currently it is not working and i do not understand the reason.
  This is my widget provider class:</p>
  
  <pre><code>public class BakingWidgetProvider extends AppWidgetProvider {
  final String myClickEvent = "click";
  void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
  
      RemoteViews remoteViews = getRecipeGridRemoteView(context);
  
      appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
  }
  
  public RemoteViews getRecipeGridRemoteView(Context context) {
      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.baking_widget_provider);
  
      Intent gridIntent = new Intent(context, GridWidgetService.class);
      views.setRemoteAdapter(R.id.grid, gridIntent);
  
      Intent appIntent = new Intent(context, MainActivity.class);
      PendingIntent intent = PendingIntent.getActivity(context, 0, appIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      views.setOnClickFillInIntent(R.id.ingredient_widget_layout, appIntent);
      views.setOnClickPendingIntent(R.id.ingredient_widget_layout, getPendingSelfIntent(context, myClickEvent));
  
  
      return views;
  }
  
   protected PendingIntent getPendingSelfIntent(Context context, String action) {
      Intent intent = new Intent(context, getClass());
      intent.setAction(action);
      return PendingIntent.getBroadcast(context, 0, intent, 0);
  }
  
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      for (int appWidgetId : appWidgetIds) {
          updateAppWidget(context, appWidgetManager, appWidgetId);
      }
  }
  
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager,
                                        int appWidgetId, Bundle newOptions) {
      updateAppWidget(context, appWidgetManager, appWidgetId);
      super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
  }
  
  @Override
  public void onEnabled(Context context) {
  }
  
  @Override
  public void onDisabled(Context context) {
  }
  
  
  @Override
  public void onReceive(Context context, Intent intent) {
      super.onReceive(context, intent);
      if (intent != null) {
          if ("android.appwidget.action.APPWIDGET_UPDATE".equals(intent.getAction())) {
              AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
              int[] appwidgetIds = appWidgetManager.getAppWidgetIds(
                      new ComponentName(context, getClass())
              );
              appWidgetManager.notifyAppWidgetViewDataChanged(appwidgetIds, R.id.grid);
              onUpdate(context, appWidgetManager, appwidgetIds);
          }
      } else if (myClickEvent.equals(intent.getAction())){
          Toast.makeText(context, "msg msgasdasd", Toast.LENGTH_SHORT).show();
      }
  }}
  </code></pre>
  
  <p>My gridview adapter class here:</p>
  
  <pre><code>public class GridWidgetService extends RemoteViewsService {
  
  @Override
  public RemoteViewsFactory onGetViewFactory(Intent intent) {
      return new GridRemoteViewsFactory(this.getApplicationContext(), intent);
  }
  
  public class GridRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
  
  
      ArrayList&lt;Ingredient&gt; ingredientsListGrid;
      Food[] foodList;
      String latestHeader;
      final String be = "bodyItem";
      Context mContext;
  
      public GridRemoteViewsFactory(Context mContext, Intent intent) {
          this.mContext = mContext;
      }
  
      @Override
      public void onCreate() {
          //foodList = getFoods();
          ingredientsListGrid = getIngredients();
          Log.wtf("INGREDIENTS SIZE", String.valueOf(ingredientsListGrid.size()));
      }
  
      @Override
      public void onDataSetChanged() {
          // foodList = getFoods();
          ingredientsListGrid = getIngredients();
      }
  
      @Override
      public void onDestroy() {
  
      }
  
      @Override
      public int getCount() {
          return (ingredientsListGrid != null) ? ingredientsListGrid.size() : 0;
      }
  
      private ArrayList&lt;Ingredient&gt; getIngredients() {
  
          Cursor ingredientCursor = mContext.getContentResolver()
                  .query(ItemsContract.IngredientEntry.CONTENT_URI_INGREDIENT_TABLE,
                          null,
                          null,
                          null,
                          null);
  
          ArrayList&lt;Ingredient&gt; ingredients = new ArrayList&lt;&gt;();
          if (ingredientCursor != null) {
              while (ingredientCursor.moveToNext()) {
                  Ingredient ingredient = getIngredientFromCursor(ingredientCursor);
                  ingredients.add(ingredient);
              }
              ingredientCursor.close();
          }
  
  
          return ingredients;
      }
  
      private Food[] getFoods() {
          Uri baseIngredientUri = ItemsContract
                  .FoodEntry
                  .CONTENT_URI_FOOD_TABLE.buildUpon().build();
  
          String ingredientUriString = baseIngredientUri.toString();
          Uri ingredientUri = Uri.parse(ingredientUriString);
  
          Cursor ingredientCursor = mContext.getContentResolver()
                  .query(ingredientUri,
                          null,
                          null,
                          null,
                          null);
  
          Food[] foods = new Food[ingredientCursor.getCount()];
          if (ingredientCursor != null) {
              while (ingredientCursor.moveToNext()) {
                  Food food = getFoodFromCursor(ingredientCursor);
                  foods[ingredientCursor.getPosition()] = (food);
              }
              ingredientCursor.close();
          }
          return foods;
      }
  
      private Food getFoodByName(String name) {
          return null;
      }
  
  
      private Ingredient getIngredientFromCursor(Cursor ingredientCursor) {
          Ingredient ingredient = new Ingredient();
  
          ingredient.setIngredient(ingredientCursor.getString(ingredientCursor
                  .getColumnIndex(ItemsContract.IngredientEntry.COLUMN_INGREDIENT_NAME)));
          ingredient.setMeasure(ingredientCursor.getString(ingredientCursor
                  .getColumnIndex(ItemsContract.IngredientEntry.COLUMN_INGREDIENT_MEASURE)));
          ingredient.setQuantity(ingredientCursor.getDouble(ingredientCursor
                  .getColumnIndex(ItemsContract.IngredientEntry.COLUMN_INGREDIENT_QUANTITY)));
  
          String name = ingredientCursor.getString(ingredientCursor
                  .getColumnIndex(ItemsContract.IngredientEntry.COLUMNS_FOOD_NAME)).replace("_", " ");
  
          if (ingredientCursor.getPosition() == 0 || !name.equals(latestHeader) || latestHeader == null) { // a sort of Section Header to divide foods ingredients
              ingredient.setFoodName(name);
              latestHeader = name;
          } else {
              ingredient.setFoodName(be + name);
          }
  
          return ingredient;
      }
  
      private Food getFoodFromCursor(Cursor foodCursor) {
          Food food = new Food();
          food.setServings(foodCursor.getInt(foodCursor
                  .getColumnIndex(ItemsContract.FoodEntry.COLUMN_FOOD_SERVINGS)));
          food.setName(foodCursor.getString(foodCursor
                  .getColumnIndex(ItemsContract.FoodEntry.COLUMN_FOOD_NAME)).replace("_", " "));
          return food;
      }
  
      @Override
      public RemoteViews getViewAt(int i) {
  
          if (ingredientsListGrid.size() == 0) {
              return null;
          }
  
          RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.widget_ingredient_item_layout);
          //  String title = ingredientsListGrid.get(i).getIngredient();
          //  String measure = ingredientsListGrid.get(i).getMeasure();
          //  Double quantity = ingredientsListGrid.get(i).getQuantity();
          Ingredient ingredient = ingredientsListGrid.get(i);
          if (ingredient.getFoodName() != null &amp;&amp; !ingredient.getFoodName().contains(be)) {
              remoteViews.setTextViewText(R.id.food_name, ingredient.getFoodName());
              remoteViews.setViewVisibility(R.id.food_name, View.VISIBLE);
          } else {
              remoteViews.setViewVisibility(R.id.food_name, View.GONE);
          }
  
          remoteViews.setTextViewText(R.id.ingredient_name, ingredientsListGrid.get(i).getIngredient());
          remoteViews.setTextViewText(R.id.ingredient_quantity, ingredient.getQuantity() + " " + ingredient.getMeasure());
          String foodName = ingredient.getFoodName();
  
  
          Bundle extras = new Bundle();
          extras.putString("foodNmae", foodName);
          Intent fillInIntent = new Intent();
          fillInIntent.putExtras(extras);
          remoteViews.setOnClickFillInIntent(R.id.ingredient_widget_layout, fillInIntent);
  
          return remoteViews;
      }
  
      @Override
      public RemoteViews getLoadingView() {
          return null;
      }
  
      @Override
      public int getViewTypeCount() {
          return 1;
      }
  
      @Override
      public long getItemId(int i) {
          return i;
      }
  
      @Override
      public boolean hasStableIds() {
          return true;
      }
  }}
  </code></pre>
  
  <p>What is wrong here? </p>