7

I can't find a way to pass extras from widget to Activity properly.

I wan't to open activity on button click with some extras passed.

    Intent intent = new Intent(context, CreateOperationsActivity.class);
    intent.putExtra("someKey", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, Constants.RequestCodes.CREATE_OPERATIONS, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setOnClickPendingIntent(R.id.add_expense_button, pendingIntent);

Activity is opened, but there is no extra in the Intent.

The only way I was able to pass that extra was seting PendingIntent flag to PendingIntent.FLAG_ONE_SHOT but then widget button works only wonce, clicking it further takes no action.

How to do that so the extra is intercepted by Activity and the button works each time?

Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157

1 Answers1

2

You're probably missing setAction() for your Intent ;) See this one for a better explanation: https://stackoverflow.com/a/3128271/515423

Community
  • 1
  • 1
vizZ
  • 1,530
  • 14
  • 14
  • It doesn't help, but the action is passed properly, contrary to extras ... so it is possible to make workaround using action. Its not clean however – Jacek Kwiecień Feb 02 '15 at 11:15