I search everywhere and couldn't find a good answer.
I'm using AlarmManager and BroadcastReceiver to send notifications at a certain time.
Below are a few lines of what I'm doing.
AlarmManager alarmManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
Calendar alarmStartTime = GregorianCalendar.getInstance();
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmStartTime.getTimeInMillis(), PendingIntent.getBroadcast(ctx, Integer.parseInt(alertID), alertIntent, PendingIntent.FLAG_UPDATE_CURRENT));
Everything works fine and I receive all the notification in the status bar. No worries about that.
My problem is: How can I cancel a certain notification before showing in status bar?
notificationManager.cancel(alertID);
will only remove the notification after is shown in the status bar.
So what is the best way to "prevent" a notification from showing to the user?
Thank you in advance!