12

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

butelo
  • 1,653
  • 1
  • 18
  • 29

5 Answers5

29

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);
Mansour Fahad
  • 721
  • 2
  • 9
  • 23
1

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

butelo
  • 1,653
  • 1
  • 18
  • 29
0

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

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

You can also use View.GONE but that will make android to fill empty space.

Rohan Kandwal
  • 9,112
  • 8
  • 74
  • 107
0

Use this :

 notificationManager.cancel(MY_NOTIFICATION_ID);
Anthony
  • 12,177
  • 9
  • 69
  • 105
Alexander Fuchs
  • 1,358
  • 3
  • 19
  • 36
  • 5
    no that's not it. that hides everything not just only progress bar – butelo Mar 20 '12 at 18:32
  • implement a second progressbar in your laout and make it invisible then you just have to call :"notification.contentView.setProgressBar(R.id.progress2, 100, progress, false);" progress2 stands for the id of your second progressbar – Alexander Fuchs Mar 20 '12 at 18:37
  • I've got a solution. Don't have to implement a second progressbar you have to implement a full new layout – butelo Mar 21 '12 at 16:08
-2

try:

 ProgressBar.setVisibilty(View.INVISIBLE) 
Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
  • 2
    it gives me nullpointer exception. first I have to get progress bar from remoteview. And I don't know how to do that – butelo Mar 21 '12 at 11:02