0

I have an App Widget.

In the App Widget I try to set 2 Pendingintests on the same Viev:

        //FIRST PENDINGINTENT
        Intent i1 = new Intent(getApplicationContext(), AppWidget.class);
        i1.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
        i1.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
        PendingIntent pi = PendingIntent.getBroadcast(
                getApplicationContext(), 0, i1,
                PendingIntent.FLAG_UPDATE_CURRENT);

        //SECONDPENDINGINTENT
        Intent i11 = new Intent(getApplicationContext(), WakeUp.class);
        PendingIntent pi1 = PendingIntent.getActivity(
                getApplicationContext(), 0, i11,0);

        //I SET THE PENDINGINTENT ON THE VIEW
        updateViews.setOnClickPendingIntent(R.id.background, pi1);
        updateViews.setOnClickPendingIntent(R.id.background, pi);

As you can see I set 2 Pendingintents (pi and pi1) on the SAME view R.id.background.

The Pendingintent pi works as it shuould.

The Pendingintent pi1 has NO EFFECT.

Please any help very much appreciated

Lisa Anne
  • 4,482
  • 17
  • 83
  • 157

1 Answers1

1

This is not possible. Any View in the RemoteViews can have only one PendingIntent for setOnClickPendingIntent(). If you call setOnClickPendingIntent() twice, the last one in wins.

Hence, please call it just once, and have WakeUp call sendBroadcast() to accomplish your second operation.

Also, please replace getApplicationContext() with this, as you do not need the application context in any of this code.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491