According to the KeyboardView.OnKeyboardActionListener.onRelease() SDK "For duplicate keys, this is called only once." However, if I set isRepeatable to true for the key “a” using the Android Softkeyboard example and the onPress() , onKey() and onRelease() log calls, I get the repetition as expected, but I am observing the following log for one click sequence / repeat / release:
I/SoftKeyboard(31467): onPress: 97 I/SoftKeyboard(31467): onKey: 97 I/SoftKeyboard(31467): onRelease: 97 I/SoftKeyboard(31467): onKey: 97 I/SoftKeyboard(31467): onRelease: 97 I/SoftKeyboard(31467): onKey: 97 I/SoftKeyboard(31467): onRelease: 97 I/SoftKeyboard(31467): onKey: 97 I/SoftKeyboard(31467): onRelease: 97 I/SoftKeyboard(31467): onKey: 97 I/SoftKeyboard(31467): onRelease: 97
How can I pinpoint when a touch device was released? Thanks D.
EDIT (Edit by Paul Boddington 07/30/2015)
Although I am not an OP, I would like to include a complete example showing the problem.
MyActivity :
public class MyActivity extends Activity { private static final String TAG = "MyActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); KeyboardView keyboardView = (KeyboardView) findViewById(R.id.keyboard_view); keyboardView.setKeyboard(new Keyboard(this, R.xml.keyboard)); keyboardView.setOnKeyboardActionListener(new KeyboardView.OnKeyboardActionListener() { @Override public void onPress(int i) { Log.i(TAG, "onPress: " + i); } @Override public void onKey(int i, int[] ints) { Log.i(TAG, "onKey: " + i); } @Override public void onRelease(int i) { Log.i(TAG, "onRelease: " + i); } @Override public void onText(CharSequence charSequence) {} @Override public void swipeLeft() {} @Override public void swipeRight() {} @Override public void swipeDown() {} @Override public void swipeUp() {} }); } }
keyboard.xml :
<?xml version="1.0" encoding="utf-8"?> <Keyboard xmlns:android="http://schemas.android.com/apk/res/android"> android:layout_height="wrap_content" android:layout_width="match_parent" > <Row android:keyWidth="25%p" android:keyHeight="60dp"> <Key android:codes="0" android:keyLabel="0" android:isRepeatable="true"/> <Key android:codes="1" android:keyLabel="1" /> <Key android:codes="2" android:keyLabel="2" /> <Key android:codes="3" android:keyLabel="3" /> </Row> </Keyboard>
activity_my.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.inputmethodservice.KeyboardView android:id="@+id/keyboard_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true" android:focusableInTouchMode="true" /> </LinearLayout>
source share