I have a question.
Im making Keystroke dynamics app on android devices.
For now, i make an activity with measure string and EditText. I want to catch KeyDown and KeyUp events on software keyboard.
My question is, what is the best way to catch KeyUp and KeyDown on Android with Java? If EditText is a good choose? If it have methods to catch any keypresses?
EDIT
I want to detect keys from string above and measure time of pressing it, (start measure on KeyDown and stop on KeyUp for example). If its possible, i want to block other keys that is not mentioned in my test string (its 9RJhl6aH0n, like in my screen)
EDIT2
What i achive so far is something like this, but my app crashes on default, when i coded line: measureText.setText(""). It works pretty ok, but still it wont trigger on KeyDown (or KeyPress). These methods runs only on KeyUp, when user just typed letter. Order is very important!
measureText.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable arg0) {
switch(measureText.getText().toString()){
case "9":
break;
case "9R":
break;
case "9RJ":
break;
case "9RJh":
break;
case "9RJhl":
break;
case "9RJhl6":
break;
case "9RJhl6a":
break;
case "9RJhl6a0":
break;
case "9RJhl6a0n":
break;
default:
measureText.getText().clear();
break;
}
return;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
return;
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
return;
}
});
from How to make KeyDown and KeyUp on android device?

No comments:
Post a Comment