0

It's intermittent and happens more often when I remove other applications as well. Hard to reproduce consistently.

I have the builder set up as follows:

if (Build.VERSION.SDK_INT >= 26) {
  CharSequence name = "Timers";
  String description = "Timer Countdown";
  int importance = NotificationManager.IMPORTANCE_DEFAULT;
  NotificationChannel channel = new NotificationChannel("1", name, importance);
  channel.setDescription(description);

  // Register the channel with the system; you can't change the importance or other notification behaviors after this.
  NotificationManager notificationManager = getSystemService(NotificationManager.class);
  notificationManager.createNotificationChannel(channel);

  notificationManagerBuilder = new NotificationCompat.Builder(this, "1");
} else {
  notificationManagerBuilder = new NotificationCompat.Builder(this);
}

notificationManagerBuilder.setSmallIcon(R.drawable.start_cycle);
notificationManagerBuilder.setAutoCancel(false);
//Higher priority will cause it to show at top of screen.
notificationManagerBuilder.setPriority(Notification.PRIORITY_DEFAULT);
notificationManagerBuilder.setDeleteIntent(dismissNotificationPendingIntent(this, 1));
notificationManagerBuilder.setContentIntent(recallAppPendingIntent());

notificationManagerCompat = NotificationManagerCompat.from(this);

And my dismiss intent is:

private PendingIntent dismissNotificationPendingIntent(Context context, int notificationId) {
  Intent dismissIntent = new Intent(context, DismissReceiver.class);
  dismissIntent.putExtra("testMethod", "launchTimer");
  dismissIntent.putExtra("Dismiss ID", notificationId);

  PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), notificationId, dismissIntent, 0);

  return dismissPendingIntent;
}

0 Answers0