Passing add-ons from widget to PendingIntent to activity

I can’t find a way to correctly transfer add-ons from widgets to Activity .

I did not open activity when I pressed a button with additional functions transferred.

  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 opens, but in Intent there is no superfluous.

The only way I could pass this additional parameter was to set the PendingIntent flag to PendingIntent.FLAG_ONE_SHOT , but then the widget button only works if clicking on it takes no action.

How to do this so that the extra interception is an Activity , and the button works every time?

+5
source share
1 answer

You are probably missing setAction() for your intention;) See this for a better explanation: fooobar.com/questions/167661 / ...

+2
source

Source: https://habr.com/ru/post/1212332/


All Articles