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
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
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);
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
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.
Use this :
notificationManager.cancel(MY_NOTIFICATION_ID);
try:
ProgressBar.setVisibilty(View.INVISIBLE)