Progress Dialog Async Task Taking Longer Time Than Expected
I am new to android programming. I am developing a web crawler for which i am using a Async Task and it is working well.In order to keep user informed,i am using progress dialog. M
Solution 1:
In you activity
// Start the progress dialog ..
Handlerhandler=newHandler() {
@OverridepublicvoidhandleMessage(Message msg) {
super.handleMessage(msg);
// dismiss the progress dialog
}
};
HttpAsyncTaskasyncTask=newHttpAsyncTask(handler);
asyncTask.execute();
In your asynctask class
privateclassHttpAsyncTaskextendsAsyncTask<List<String>, Integer, List<String>> {
private Handler handler = null;
public HttpAsyncTask (Handler handler) {
this.handler = handler;
}
protectedVoid doInBackground(Void... params) {
//Perform your task// When you know that task is finished , fire following codeif (null != handler) {
Message message = handler.obtainMessage();
message.obj = Any data you want to sent to the activity
message.what = 1 ; ( Optional )
handler.sendMessage(message);
}
}
Thus when sendMessage function is called from doInbackground.. your handleMessage in your activity will get triggered and then you should dismiss the progress dialog
Hope this will improve the performance issue what you are facing
Solution 2:
Remove super.onPreExecute(); in onPreExecute() method and check .It might Help
Post a Comment for "Progress Dialog Async Task Taking Longer Time Than Expected"