Hi every one, I have this code in android. But when the Thread begging the loading in freezing. How I can prevent the freezing. here the code:
private void reload(final String criteria) { try { myProgressDialog = ProgressDialog.show(myfiles.this, "Please wait...", "Loading Your Photos... Please Wait", false);
new Thread() { public void run() { try {
Thread.sleep(2000);
} catch (Exception e) {
}
runOnUiThread(new Runnable() {
@Override
public void run() {
// Fetch the fact
try {
/* here my code */
} catch (Exception e) {
myProgressDialog.dismiss();
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
// Dismiss the Dialog
myProgressDialog.dismiss();
}
}.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
}