title: Notifications are being delayed in Android Oreo
body: <p>I'm working in a reminder application that has worked well in Marshmallow but I have just bought an Xperia XZ1 compact with Android Oreo and notifications are being delayed or maybe even not shown at all. When the time of the reminder goes off, the phone does nothing, but if I unlock the screen then the notification suddenly appears. According to the logs of the application, my broadcast receiver works and receives the alarm in time and then generates a notification successfully. But the system is delaying to show the notification and I don't know the reason. My application has got all the notification permissions, is configured for being ignored from battery saver and so on. Here is the code for showing the notification. As I said, this code always gets executed in time, but the sound of the notification is delayed a random quantity of minutes, or until I turn the screen on manually.</p>
  
  <p>Is there any way to fix this?</p>
  
  <pre><code>private void makeNotification(Long rowId, String title, String body) {
      android.app.NotificationManager mgr = (android.app.NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);
      Intent notificationIntent;
  
      long notificationId;
      PendingIntent pi;
      if (rowId == null) {
          notificationId = 0;
          notificationIntent = new Intent(context, ReminderListActivity.class);
          pi = PendingIntent.getActivity(context, 0, notificationIntent,
                  PendingIntent.FLAG_UPDATE_CURRENT);
      } else {
          notificationId = rowId;
          notificationIntent = new Intent(context, ReminderEditActivity.class);
          notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);
          long rowIdPrimitive = rowId;
          pi = PendingIntent.getActivity(context, (int)rowIdPrimitive, notificationIntent,
                  PendingIntent.FLAG_ONE_SHOT);
      }
  
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
              .setSmallIcon(android.R.drawable.stat_sys_warning)
              .setContentTitle(title)
              .setContentText(body)
              .setContentIntent(pi)
              .setStyle(new NotificationCompat.BigTextStyle().bigText(body));
  
      Notification note = mBuilder.build();
  
      note.defaults |= Notification.DEFAULT_SOUND;
      note.flags |= Notification.FLAG_AUTO_CANCEL;
  
      // An issue could occur if user ever enters over 2,147,483,647 tasks. (Max int value).
      // I highly doubt this will ever happen. But is good to note.
      int id = (int)((long)notificationId);
      mgr.notify(id, note);
      NotificationManager.setNotified(context, id);
  }
  </code></pre>