Вы можете попробовать вспомогательный метод ниже:
private void longPress(int key) {
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
KeyEvent event1 = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_DOWN, key, 0);
KeyEvent event2 = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_DOWN, key, 1);
getInstrumentation().sendKeySync(event1);
getInstrumentation().sendKeySync(event2);
}
И пример использования:
longPress(KeyEvent.KEYCODE_ENTER);