Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide notification area progress bar in android when 100% is completed

I'm using this tutorial

to show a notification with a progress bar.

Everything works fine.

But I can not make the progress dissapear when the task is 100% done

How can I do this? tx

like image 548
butelo Avatar asked Mar 20 '12 18:03

butelo


2 Answers

Here it is:

Notification.setProgress(0, 0, false);

Where the first param stands for min and the second param stands for the maximum value. Don’t forget to call:

Notification.notify(id, NotificationManager);
like image 134
Mansour Fahad Avatar answered Oct 22 '22 15:10

Mansour Fahad


I found a "solution" that works.

Just call a new RemoteView with no progress bar on it's layout when the task is done

In the tutorial I use I have this progress.xml called:

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

when the task is 100% done call:

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

so layout done.xml replaces progress.xml

like image 23
butelo Avatar answered Oct 22 '22 17:10

butelo