I have thread which calls a method and if any exception occurs it returns to the catch block of that thread.
later, then i like to call a handler or toast message to display the exception but i couldn’t call it to display an error.
what should i have to do to solve the problem, any idea.
thanks in advance.
private void onSaveDialog() {
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setTitle("mApprove Advantage");
dialog.setIcon(R.drawable.mapprove1);
dialog.setMessage("Theme setting is in progress...");
dialog.setIndeterminate(false);
dialog.setCancelable(false);
dialog.show();
new Thread() {
@Override
public void run() {
try {
Thread.sleep(5000);
synchronized (this) {
onsave();
}
dialog.cancel();
onSetting();
} catch (Exception e) {
dialog.cancel();
wrongurl=true;
onFinishDialog1();
System.out.println("url wrong");
}
}
}.start();
}
private void onFinishDialog1(){
if(wrongurl){
wrongurl=false;
Toast.makeText(getApplicationContext(),
"URL not Available.", Toast.LENGTH_LONG)
.show();
}
}
Use this :
Thanks.