Progress Bar In Notification Area Is Not Closing And Not Starting The Second Progress Bar
Solution 1:
PendingIntentcontentIntent= PendingIntent.getActivity(this, 0, intent, 0);
1- in this above line, the 2nd parameter in getActivity() is requestCode, it should be a unique number for each button. currently it is 0 for both buttons.
notificationManager.notify(42, notification);
2- in the above line, the notification index you are passing as 42, it should be unique for both buttons. currently no matter how many buttons you create it will never show you a new notification because you are passing 42 for each. it will keep updating the current one.
also you might need to look again the code you are doing in onHandleIntent(). there are better ways to do this.
Solution 2:
What you need is an AsyncTask
and a ListView
.
Your downloadmagic happens in AsyncTask.
Make for example an Array that indicates which download is running and the progress of each running download.
Now in your AsyncTask there is a publishProgress
-Method which calls onProgressUpdate
.
In onProgressUpdate
you have to update the respective progress-variable and call notifyDataSetChanged
on your ListView Adapter.
This will cause the ListView to reload all Data.
Finally in your ListView
-Adapter you got a Method getView
, where you have to create the View for each row of your ListView.
There you can decide to show the ProgressBar (download running) or not.
More Information about AsyncTask can be found here: http://labs.makemachine.net/2010/05/android-asynctask-example/ And more about the ListView here: Android : BaseAdapter how to?
Post a Comment for "Progress Bar In Notification Area Is Not Closing And Not Starting The Second Progress Bar"