I am trying to dismiss an AlertDialog in android:
public AlertDialog dialog;
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
builder.setMessage("Message.");
dialog= builder.create();
dialog.show();
Thread thread = new Thread(this);
thread.start();
public void run() {
Looper.prepare();
//some code
handler.sendEmptyMessage(0);
Looper.loop();
}
Handler handler= new Handler() {
@Override public void handleMessage(Message msg)
{ dialog.dismiss();
//some code
}
};
It doesn't work. I have searched and tried several proposed methods, and they were all unsuccessful. Any help is appreciated.