Yes i have a indeterminate progressBar in the header, the spinner one, but
im using broadcast to all the activities which have the spinner to show or
hide it if there's a task running in the background.... :
@Override
protected void onPreExecute() {
Logger.write("QuadrosMobileActivityTask ", " AsyncTask pre execution "+
"Current Activity: "+activity.getClass().getName(), Logger.INFO);
Intent broadcast = new Intent();
broadcast.setAction("SHOW_PROGRESSBAR");
mApp.sendBroadcast(broadcast);
mApp.setProgressBarInitialState(ProgressBar.VISIBLE);
}
@Override
protected Object doInBackground(Void... params) {
*do{*
* SystemClock.sleep(50); *
* }while(activity==null);*
*
*
* Logger.write("QuadrosMobileActivityTask ", " AsyncTask background
initialized "+"Current Activity: "+activity.getClass().getName(),
Logger.INFO);*
* return activity.doBackGroundRequest();//method implemented by all sub
activities*
}
@Override
protected void onPostExecute(Object result) {
if(activity!=null){
Logger.write("QuadrosMobileActivityTask ", " AsyncTask post execution
"+"Current Activity: "+activity.getClass().getName(), Logger.INFO);
//update results
activity.updateResultsInUi(result);
mApp.getAsyncTasks().remove(this);
//check if there's more tasks in the collection
if(mApp.getAsyncTasks().isEmpty()){
Intent broadcast = new Intent();
broadcast.setAction("HIDE_PROGRESSBAR");
mApp.sendBroadcast(broadcast);
mApp.setProgressBarInitialState(ProgressBar.GONE);
}
}
}
the bold text is the one that gives problems.....but in the pre and post
there's no problem having the activity reference...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en