When using a AsyncTaskLoader how would you update a progressbar showing the status as it is being updated? Normally you wait for the callback to remove when done, but how to do
You can use handler, i think it will be lighter for system than intent
public class MyFragmentActivity extends FragmentActivity{
private final static int MSGCODE_PROGRESS = 1;
private final static int MSGCODE_SIZE = 2;
private final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
if(null != bundle){
int data = msg.getData().getInt(BUNDLE_PROGRESS);
if(msg.what == MSGCODE_SIZE){
mProgressBar.setMax(data);
} else if(msg.what == MSGCODE_PROGRESS){
mProgressBar.setProgress(data);
}
}
}
};
}
Set mHandler to constructor of AsyncTaskLoader and from loadInBackground you can update progress
Bundle bundle = new Bundle();
bundle.putInt(BUNDLE_PROGRESS, lenghtOfFile);
Message msg = new Message();
msg.setData(bundle);
msg.what = MSGCODE_SIZE;
mHandler.sendMessage(msg);