我正在尝试实现此代码
if(someCondition){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("message")
.setPositiveButton("Yes", this)
.setNegativeButton("No", this);
builder.show();
}
finish();
问题是活动在显示对话框之前调用完成(),因此它引发以下异常
MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40704090 that was originally added here
如何处理?