4

I'm create a BigPictureStyle notification with progress bar for a photo upload and it mostly works as it should.

The issue is: if the user collapsed the notification on the notification tray, next time the notification is updated it will expand it again. Is that something I can control? Can I chance the code so the system will keep the notification on the way the user put 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 keeping the reference to the Notification object generated by the builder and make changes only to the RemoteView no success.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • If your notification is the only notification shown, I believe the notification bar automatically expands the notification, and collapses it when another notification joins it. Dismiss that notification, and your notification will expand again because it is back to being the only one displayed. – Neilers Jun 30 '14 at 20:00

0 Answers0