Update expandable notification, re-expand it, even after the user dumped it

I am creating a BigPictureStyleprogress bar notification to upload photos and basically works as it should.

The problem is this: if the user drops the notification into the notification tray, the next time the notification is updated, it will expand it again. Is this something I can control? Can I use the code so that the system saves a notification about how the user placed it?

Below is the code:

  NotificationCompat.Builder b = new NotificationCompat.Builder(App.the());
  b.setSmallIcon(R.drawable.actionbar_icon);
  b.setContentTitle(title);
  b.setContentText(content);
  b.setTicker(title);
  b.setWhen(time);
  b.setOnlyAlertOnce(true);
  b.setOngoing(true);
  b.setProgress(100, progress, false);

  NotificationCompat.BigPictureStyle s = new NotificationCompat.BigPictureStyle();
  s.setBigContentTitle(title);
  s.setSummaryText(content);
  s.bigPicture(photo);
  b.setStyle(s);

  b.setContentIntent( /* sets the activity to open */ );
  b.addAction( /* adds the cancel button */ );

  NotificationManager mn = ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
  mn.notify(ONGOING_NOTIFICATION, b.build());

ps .: I also tried to keep a reference to the object Notificationgenerated by the constructor, and only make changes RemoteViewwithout success.

+4

Source: https://habr.com/ru/post/1538036/


All Articles