I have a dialog showing up using this code:
Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("New game")
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
clear();
}
}).show();
but when I rotate my screen i get an error : android.view.WindowLeaked
and i dont know why.
I tried writing dialog.dismiss()
and dialog.cancel()
in the onClick function of the dialog but it didnt work.
Thank you!