I have an application that performs a long task and returns a value. During task a ProgressDialogshows progress. After completing the task, I want to show the result in TextView. I am running a task in FutureTask.
My problem is that if I try to get the result, the .get()FutureTask method blocks the UI thread and I don't see ProgressDialog( TextViewdisplays the result properly).
My code for the task (pool - ExecutorService):
final FutureTask<String> future = new FutureTask<String>(new Callable<String>() {
@Override
public String call() {
return myLongTask();
}
});
pool.execute(future);
And after that I call updateProgressBar()in Runnable, which updates ProgressDialogwith Handler:
Runnable pb = new Runnable() {
public void run() {
myUpdateProgressBar();
}
};
pool.execute(pb);
, , ProgressDialog:
String result = future.get()
updateProgressBar() ( ) ProgressDialog, :
, , .
, ? ( AsyncTasks, , .)