I’m trying to implement this code
if(someCondition){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("message")
.setPositiveButton("Yes", this)
.setNegativeButton("No", this);
builder.show();
}
finish();
The problem is that the activity calls finish() before dialog is shown up so it throws the following exception
MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40704090 that was originally added here
How to handle that?
And in the Handler for the button click put the finish again.