'Debugging in Android Studio, onKey only runs if I have a breakpoint
I have an issue related to onKey method. When I am debugging with a breakpoint on the first if, the app works correctly, but when I am excuting without the breakpoint, it seems like keycode i (288 - KEYCODE_SCAN_CENTER) is not captured at all. How can i solve this issue?
et_confirmar_caja.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (!TextUtils.isEmpty(et_confirmar_caja.getText().toString()) && keyEvent.getAction()!=KeyEvent.ACTION_DOWN) {
if(i>=286 && i<=288){
if(et_confirmar_caja.getText().toString().equals(tv_caja_inventario.getText().toString())){
Tipo_inventario tipo_inventario = new Tipo_inventario();
tipo_inventario.execute(str_id_inventario);
}else{
error.start();
final AlertDialog.Builder dialogo = new AlertDialog.Builder(context);
dialogo.setCancelable(false);
dialogo.setTitle("Titulo");
dialogo.setMessage("La ubicacion no corresponde");
dialogo.setPositiveButton("Entendido", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
et_confirmar_caja.setText("");
et_confirmar_caja.requestFocus();
}
});
dialogo.create();
dialogo.show();
}
}
}
return false;
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
