This snippet creates a ProgressDialog and a thread to execute something with an unknown duration (web service as an example). When this "thing" finishes, a message is sent to the parent of the thread to stop the ProgessDialog.
final ProgressDialog dialog = ProgressDialog.show(this, "Title",
"Message", true);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
dialog.dismiss();
}
};
Thread checkUpdate = new Thread() {
public void run() {
//
// YOUR LONG CALCULATION (OR OTHER) GOES HERE
//
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
0 comments: