Buenas, estoy tratando de cerrar una app, pero al darle salir me cierra la actividad y me la vuelve a abrir.
En el logcat me sale esto:
Attempted to finish an input event but the input event receiver has already been disposed
.
Estoy usando estos códigos:
private void salir()
{
final CharSequence[] option = {"Sí","No"};
final AlertDialog.Builder builder = new AlertDialog.Builder(Login.this);
builder.setTitle("¿Desea salir?");
builder.setItems(option, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (option[which]=="Sí"){
finishAffinity();
}
else if(option[which] == "No"){
dialog.dismiss();
}
}
});
builder.show();
}
@Override
public boolean onKeyDown (int KeyCode, KeyEvent event)
{
if(KeyCode == event.KEYCODE_BACK)
{
salir();
}
return super.onKeyDown(KeyCode,event);
}
finish()
)?finish
usofinishAffinity();