I’m trying to get my Notification to not cancel when the user presses “Clear All” So far I have the intent working properly on everything except this:
Intent intent = new Intent(getBaseContext(), MainActivity.class);
intent.addFlags(Notification.FLAG_ONGOING_EVENT);
intent.addFlags(Notification.FLAG_NO_CLEAR);
PendingIntent contentIntent = PendingIntent.getActivity(
getBaseContext(), 0, intent, 0);
The question I have at this point is: Are my flags correct?
Yes, your flags look pretty much correct, although I don’t know if you even need the
FLAG_NO_CLEAR. I currently have an app which creates an ongoing (non-cancellable) notification – I only use theFLAG_ONGOING_EVENTand it works fine for me. I pretty much just copied it from a tutorial and then added the ongoing event flag.Here’s some sample code: