I am trying to create a PendingIntent in Android. Here is the code
mNotificationIntent = new Intent(getApplicationContent(), MyAlarm.class);
mContentIntent = PendingIntent.getActivity(getApplicationContext(),
0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
and I am getting the following error:
Must be one or more of: PendingIntent.FLAG_ONE_shot,PendingIntent.FLAG_NO_CREATE,
PendingIntent.FLAG_UPDATE_CURRENT,
Intent.FILL_IN_ACTION, Intent.FILL_IN_DATA, Intent.FILL_IN_CATEGORIES…..)
Why is this error showing ? How to resolve this? Please help. Thank you.
You are passing Intent.FLAG_ACTIVITY_NEW_TASK
when the method call expects a PendingIntent
flag. If you want to add Intent.FLAG_ACTIVITY_NEW_TASK
to your Intent
, you need to do it like this:
mNotificationIntent = new Intent(getApplicationContent(), MyAlarm.class);
mNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContentIntent = PendingIntent.getActivity(getApplicationContext(),
0, mNotificationIntent, 0);
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