Hide the notification area control panel in android when 100% complete

I use this tutorial

to show a progress bar notification.

Everything is working fine.

But I can’t make progress disappear when the task is 100% complete

How can i do this? TX

+6
source share
5 answers

There he is:

Notification.setProgress(0, 0, false); 

If the first parameter is min and the second parameter is the maximum value. Do not forget to call:

 Notification.notify(id, NotificationManager); 
+19
source

I found a "solution" that works.

Just call the new RemoteView without a progress bar on its layout when the task is completed

In the tutorial that I'm using, I have this progress.xml:

  notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progress); 

when the task makes a 100% call:

  notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.done); 

so layout done.xml replaces progress.xml

+1
source

Use this:

  notificationManager.cancel(MY_NOTIFICATION_ID); 
0
source

To remove ProgressBar from RemoteView , use the following code: -

  remoteViews.setViewVisibility(R.id.progressBar, View.INVISIBLE); 

You can also use View.GONE , but it will make android to fill the empty space.

0
source

to try:

  ProgressBar.setVisibilty(View.INVISIBLE) 
-1
source

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


All Articles