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?
You're probably missing setAction()
for your Intent ;) See this one for a better explanation: https://stackoverflow.com/a/3128271/515423
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With