0

I set a notification progress bar for my users to show when they're uploading files but when the notification start it shows on top of the screen and vibrate and it make sounds. I don't want that, I just want the notification on the status, thats all. Here's my code.

final double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
final int currentprogress = (int) progress;
String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(MultiPost.this, NOTIFICATION_CHANNEL_ID);

builder.setDefaults(Notification.DEFAULT_LIGHTS | DEFAULT_SOUND)
   .setVibrate(new long[]{0L})// Passing null here silently fails
   .setContentTitle("2 " +getResources().getString(R.string.on) +" " + String.valueOf(fileUriList.size()))
   .setContentText("" + (int)progress +"%")
   .setAutoCancel(false)
   .setOngoing(true)
   .setWhen(System.currentTimeMillis())
   .setPriority(NotificationCompat.PRIORITY_DEFAULT)
   .setSmallIcon(R.mipmap.ic_launcher);

builder.setProgress(100,currentprogress,false);
mNotifyManager.notify(1001,builder.build());
Munim Munna
  • 17,178
  • 6
  • 29
  • 58

0 Answers0