List of usage examples for android.view KeyEvent KEYCODE_NUMPAD_ENTER
int KEYCODE_NUMPAD_ENTER
To view the source code for android.view KeyEvent KEYCODE_NUMPAD_ENTER.
Click Source Link
From source file:Main.java
/** * Checks whether the given event is any of ENTER or NUMPAD ENTER. * @param event Event to be checked./*from w w w.j a va 2 s .c om*/ * @return Whether the event should be processed as ENTER. */ public static boolean isEnter(KeyEvent event) { return isActionUp(event) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER); }
From source file:org.deviceconnect.android.deviceplugin.host.activity.KeyEventProfileActivity.java
@Override public boolean onTouch(final View v, final MotionEvent event) { int action = event.getAction(); // Emulate ten key down/up event. switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: KeyEvent keyevent = null; int i = v.getId(); if (i == R.id.button_0) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_0); } else if (i == R.id.button_1) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_1); } else if (i == R.id.button_2) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_2); } else if (i == R.id.button_3) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_3); } else if (i == R.id.button_4) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_4); } else if (i == R.id.button_5) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_5); } else if (i == R.id.button_6) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_6); } else if (i == R.id.button_7) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_7); } else if (i == R.id.button_8) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_8); } else if (i == R.id.button_9) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_9); } else if (i == R.id.button_dot) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_DOT); } else if (i == R.id.button_enter) { keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_ENTER); } else if (i == R.id.button_keyevent_close) { finish();//from w w w. j a va 2 s . co m } if (keyevent != null) { dispatchKeyEvent(keyevent); } break; default: break; } return false; }
From source file:org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin.java
private boolean handleSpecialKey(int key, boolean shift, boolean ctrl, boolean alt) { int keyEvent = specialKeyMap.get(key, 0); if (keyEvent == 0) return false; InputConnection inputConn = RemoteKeyboardService.instance.getCurrentInputConnection(); // Log.d("RemoteKeyboardPlugin", "Handling special key " + key + " translated to " + keyEvent + " shift=" + shift + " ctrl=" + ctrl + " alt=" + alt); // special sequences: if (ctrl && (keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT)) { // Ctrl + right -> next word ExtractedText extractedText = inputConn.getExtractedText(new ExtractedTextRequest(), 0); int pos = getCharPos(extractedText, ' ', keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT); if (pos == -1) pos = currentTextLength(extractedText); else/*w w w . j a va 2s .c o m*/ pos++; int startPos = pos; int endPos = pos; if (shift) { // Shift -> select word (otherwise jump) Pair<Integer, Integer> sel = currentSelection(extractedText); int cursor = currentCursorPos(extractedText); // Log.d("RemoteKeyboardPlugin", "Selection (to right): " + sel.first + " / " + sel.second + " cursor: " + cursor); startPos = cursor; if (sel.first < cursor || // active selection from left to right -> grow sel.first > sel.second) // active selection from right to left -> shrink startPos = sel.first; } inputConn.setSelection(startPos, endPos); } else if (ctrl && keyEvent == KeyEvent.KEYCODE_DPAD_LEFT) { // Ctrl + left -> previous word ExtractedText extractedText = inputConn.getExtractedText(new ExtractedTextRequest(), 0); int pos = getCharPos(extractedText, ' ', keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT); if (pos == -1) pos = 0; else pos++; int startPos = pos; int endPos = pos; if (shift) { Pair<Integer, Integer> sel = currentSelection(extractedText); int cursor = currentCursorPos(extractedText); // Log.d("RemoteKeyboardPlugin", "Selection (to left): " + sel.first + " / " + sel.second + " cursor: " + cursor); startPos = cursor; if (cursor < sel.first || // active selection from right to left -> grow sel.first < sel.second) // active selection from right to left -> shrink startPos = sel.first; } inputConn.setSelection(startPos, endPos); } else if (shift && (keyEvent == KeyEvent.KEYCODE_DPAD_LEFT || keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT || keyEvent == KeyEvent.KEYCODE_DPAD_UP || keyEvent == KeyEvent.KEYCODE_DPAD_DOWN || keyEvent == KeyEvent.KEYCODE_MOVE_HOME || keyEvent == KeyEvent.KEYCODE_MOVE_END)) { // Shift + up/down/left/right/home/end long now = SystemClock.uptimeMillis(); inputConn.sendKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0)); inputConn.sendKeyEvent( new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyEvent, 0, KeyEvent.META_SHIFT_LEFT_ON)); inputConn.sendKeyEvent( new KeyEvent(now, now, KeyEvent.ACTION_UP, keyEvent, 0, KeyEvent.META_SHIFT_LEFT_ON)); inputConn.sendKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0)); } else if (keyEvent == KeyEvent.KEYCODE_NUMPAD_ENTER || keyEvent == KeyEvent.KEYCODE_ENTER) { // Enter key EditorInfo editorInfo = RemoteKeyboardService.instance.getCurrentInputEditorInfo(); // Log.d("RemoteKeyboardPlugin", "Enter: " + editorInfo.imeOptions); if (editorInfo != null && (((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0) || ctrl)) { // Ctrl+Return overrides IME_FLAG_NO_ENTER_ACTION (FIXME: make configurable?) // check for special DONE/GO/etc actions first: int[] actions = { EditorInfo.IME_ACTION_GO, EditorInfo.IME_ACTION_NEXT, EditorInfo.IME_ACTION_SEND, EditorInfo.IME_ACTION_SEARCH, EditorInfo.IME_ACTION_DONE }; // note: DONE should be last or we might hide the ime instead of "go" for (int i = 0; i < actions.length; i++) { if ((editorInfo.imeOptions & actions[i]) == actions[i]) { // Log.d("RemoteKeyboardPlugin", "Enter-action: " + actions[i]); inputConn.performEditorAction(actions[i]); return true; } } } else { // else: fall back to regular Enter-event: // Log.d("RemoteKeyboardPlugin", "Enter: normal keypress"); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEvent)); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent)); } } else { // default handling: inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEvent)); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent)); } return true; }
From source file:org.deviceconnect.android.deviceplugin.host.activity.KeyEventProfileActivity.java
/** * Get Configure string.//from w ww .j av a 2s. co m * * @param keymode Key Mode. * @param keyId Key ID. * @return config Configure string. */ private String getConfig(final KeyMode keymode, final int keyId) { String config = ""; int nIndex = -1; switch (keyId) { case KeyEvent.KEYCODE_NUMPAD_0: nIndex = 0; break; case KeyEvent.KEYCODE_NUMPAD_1: nIndex = 1; break; case KeyEvent.KEYCODE_NUMPAD_2: nIndex = 2; break; case KeyEvent.KEYCODE_NUMPAD_3: nIndex = 3; break; case KeyEvent.KEYCODE_NUMPAD_4: nIndex = 4; break; case KeyEvent.KEYCODE_NUMPAD_5: nIndex = 5; break; case KeyEvent.KEYCODE_NUMPAD_6: nIndex = 6; break; case KeyEvent.KEYCODE_NUMPAD_7: nIndex = 7; break; case KeyEvent.KEYCODE_NUMPAD_8: nIndex = 8; break; case KeyEvent.KEYCODE_NUMPAD_9: nIndex = 9; break; case KeyEvent.KEYCODE_NUMPAD_DOT: nIndex = 10; break; case KeyEvent.KEYCODE_NUMPAD_ENTER: nIndex = 11; break; default: nIndex = -1; break; } if (nIndex != -1) { switch (mKeyMode) { case MEDIA_CTRL: config = mConfigMediaCtrl[nIndex]; break; case DPAD_BUTTON: config = mConfigDpad[nIndex]; break; case USER: config = mConfigUser[nIndex]; break; case STD_KEY: default: config = mConfigStdKey[nIndex]; break; } } else { config = ""; } return config; }
From source file:website.openeng.anki.Reviewer.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { char keyPressed = (char) event.getUnicodeChar(); if (mAnswerField != null && !mAnswerField.isFocused()) { if (sDisplayAnswer) { if (keyPressed == '1') { answerCard(EASE_1);/*from w w w . ja v a 2s . c o m*/ return true; } if (keyPressed == '2') { answerCard(EASE_2); return true; } if (keyPressed == '3') { answerCard(EASE_3); return true; } if (keyPressed == '4') { answerCard(EASE_4); return true; } if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { answerCard(getDefaultEase()); return true; } } if (keyPressed == 'e') { editCard(); return true; } if (keyPressed == '*') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_MARK_CARD, mMarkCardHandler, new DeckTask.TaskData(mCurrentCard, 0)); return true; } if (keyPressed == '-') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 4)); return true; } if (keyPressed == '=') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 0)); return true; } if (keyPressed == '@') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 1)); return true; } if (keyPressed == '!') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 2)); return true; } if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) { playSounds(true); return true; } } return super.onKeyUp(keyCode, event); }
From source file:com.ichi2.anki.Reviewer.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { char keyPressed = (char) event.getUnicodeChar(); if (mAnswerField != null && !mAnswerField.isFocused()) { if (sDisplayAnswer) { if (keyPressed == '1') { answerCard(EASE_1);//from w w w .ja v a2 s. c om return true; } if (keyPressed == '2') { answerCard(EASE_2); return true; } if (keyPressed == '3') { answerCard(EASE_3); return true; } if (keyPressed == '4') { answerCard(EASE_4); return true; } if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { answerCard(getDefaultEase()); return true; } } if (keyPressed == 'e') { editCard(); return true; } if (keyPressed == '*') { onMark(mCurrentCard); refreshActionBar(); return true; } if (keyPressed == '-') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 4)); return true; } if (keyPressed == '=') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 0)); return true; } if (keyPressed == '@') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 1)); return true; } if (keyPressed == '!') { DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDismissCardHandler, new DeckTask.TaskData(mCurrentCard, 2)); return true; } if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) { playSounds(true); return true; } // different from Anki Desktop if (keyPressed == 'z') { undo(); return true; } } return super.onKeyUp(keyCode, event); }
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (mAnswerField != null && !mAnswerField.isFocused()) { if (!sDisplayAnswer) { if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { displayCardAnswer();/*w ww.j a v a2 s . com*/ return true; } } } return super.onKeyUp(keyCode, event); }
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
protected void initControls() { mCardFrame.setVisibility(View.VISIBLE); if (mShowRemainingCardCount) { mTextBarNew.setVisibility(View.VISIBLE); mTextBarLearn.setVisibility(View.VISIBLE); mTextBarReview.setVisibility(View.VISIBLE); }//from w w w . java 2 s .c om mChosenAnswer.setVisibility(View.VISIBLE); mFlipCardLayout.setVisibility(View.VISIBLE); mAnswerField.setVisibility(typeAnswer() ? View.VISIBLE : View.GONE); mAnswerField.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { displayCardAnswer(); return true; } return false; } }); mAnswerField.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER)) { displayCardAnswer(); return true; } return false; } }); }
From source file:com.android.tv.MainActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { /*/*from w w w . j a v a2s. co m*/ * The following keyboard keys map to these remote keys or "debug actions" * - -------- * A KEYCODE_MEDIA_AUDIO_TRACK * D debug: show debug options * E updateChannelBannerAndShowIfNeeded * I KEYCODE_TV_INPUT * O debug: show display mode option * P debug: togglePipView * S KEYCODE_CAPTIONS: select subtitle * W debug: toggle screen size * V KEYCODE_MEDIA_RECORD debug: record the current channel for 30 sec * X KEYCODE_BUTTON_X KEYCODE_PROG_BLUE debug: record current channel for a few minutes * Y KEYCODE_BUTTON_Y KEYCODE_PROG_GREEN debug: Play a recording */ if (SystemProperties.LOG_KEYEVENT.getValue()) { Log.d(TAG, "onKeyUp(" + keyCode + ", " + event + ")"); } // If we are in the middle of channel change, finish it before showing overlays. finishChannelChangeIfNeeded(); if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) { showSearchActivity(); return true; } switch (mOverlayManager.onKeyUp(keyCode, event)) { case KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY: return super.onKeyUp(keyCode, event); case KEY_EVENT_HANDLER_RESULT_HANDLED: return true; case KEY_EVENT_HANDLER_RESULT_NOT_HANDLED: return false; case KEY_EVENT_HANDLER_RESULT_PASSTHROUGH: default: // pass through } if (mSearchFragment.isVisible()) { if (keyCode == KeyEvent.KEYCODE_BACK) { getFragmentManager().popBackStack(); return true; } return super.onKeyUp(keyCode, event); } if (keyCode == KeyEvent.KEYCODE_BACK) { // When the event is from onUnhandledInputEvent, onBackPressed is not automatically // called. Therefore, we need to explicitly call onBackPressed(). onBackPressed(); return true; } if (!mChannelTuner.areAllChannelsLoaded()) { // Now channel map is under loading. } else if (mChannelTuner.getBrowsableChannelCount() == 0) { switch (keyCode) { case KeyEvent.KEYCODE_CHANNEL_UP: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_CHANNEL_DOWN: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_NUMPAD_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_E: case KeyEvent.KEYCODE_MENU: showSettingsFragment(); return true; } } else { if (KeypadChannelSwitchView.isChannelNumberKey(keyCode)) { showKeypadChannelSwitchView(keyCode); return true; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: if (!PermissionUtils.hasModifyParentalControls(this)) { // TODO: support this feature for non-system LC app. b/23939816 return true; } PinDialogFragment dialog = null; if (mTvView.isScreenBlocked()) { dialog = new PinDialogFragment(PinDialogFragment.PIN_DIALOG_TYPE_UNLOCK_CHANNEL, new PinDialogFragment.ResultListener() { @Override public void done(boolean success) { if (success) { unblockScreen(mTvView); mIsCurrentChannelUnblockedByUser = true; } } }); } else if (mTvView.getBlockedContentRating() != null) { final TvContentRating rating = mTvView.getBlockedContentRating(); dialog = new PinDialogFragment(PinDialogFragment.PIN_DIALOG_TYPE_UNLOCK_PROGRAM, new PinDialogFragment.ResultListener() { @Override public void done(boolean success) { if (success) { mLastAllowedRatingForCurrentChannel = rating; mTvView.unblockContent(rating); } } }); } if (dialog != null) { mOverlayManager.showDialogFragment(PinDialogFragment.DIALOG_TAG, dialog, false); } return true; case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_NUMPAD_ENTER: case KeyEvent.KEYCODE_E: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_MENU: if (event.isCanceled()) { // Ignore canceled key. // Note that if there's a TIS granted RECEIVE_INPUT_EVENT, // fallback keys not blacklisted will have FLAG_CANCELED. // See dispatchKeyEvent() for detail. return true; } if (keyCode != KeyEvent.KEYCODE_MENU) { updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_FORCE_SHOW); } if (keyCode != KeyEvent.KEYCODE_E) { mOverlayManager.showMenu( mTvView.isRecordingPlayback() ? Menu.REASON_RECORDING_PLAYBACK : Menu.REASON_NONE); } return true; case KeyEvent.KEYCODE_CHANNEL_UP: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_CHANNEL_DOWN: case KeyEvent.KEYCODE_DPAD_DOWN: // Channel change is already done in the head of this method. return true; case KeyEvent.KEYCODE_S: if (!SystemProperties.USE_DEBUG_KEYS.getValue()) { break; } case KeyEvent.KEYCODE_CAPTIONS: { mOverlayManager.getSideFragmentManager().show(new ClosedCaptionFragment()); return true; } case KeyEvent.KEYCODE_A: if (!SystemProperties.USE_DEBUG_KEYS.getValue()) { break; } case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { mOverlayManager.getSideFragmentManager().show(new MultiAudioFragment()); return true; } case KeyEvent.KEYCODE_GUIDE: { mOverlayManager.showProgramGuide(); return true; } case KeyEvent.KEYCODE_INFO: { mOverlayManager.showBanner(); return true; } } } if (SystemProperties.USE_DEBUG_KEYS.getValue()) { switch (keyCode) { case KeyEvent.KEYCODE_W: { mDebugNonFullSizeScreen = !mDebugNonFullSizeScreen; if (mDebugNonFullSizeScreen) { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTvView.getLayoutParams(); params.width = 960; params.height = 540; params.gravity = Gravity.START; mTvView.setLayoutParams(params); } else { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTvView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.CENTER; mTvView.setLayoutParams(params); } return true; } case KeyEvent.KEYCODE_P: { togglePipView(); return true; } case KeyEvent.KEYCODE_CTRL_LEFT: case KeyEvent.KEYCODE_CTRL_RIGHT: { mUseKeycodeBlacklist = !mUseKeycodeBlacklist; return true; } case KeyEvent.KEYCODE_O: { mOverlayManager.getSideFragmentManager().show(new DisplayModeFragment()); return true; } case KeyEvent.KEYCODE_D: mOverlayManager.getSideFragmentManager().show(new DebugOptionFragment()); return true; case KeyEvent.KEYCODE_MEDIA_RECORD: // TODO(DVR) handle with debug_keys set case KeyEvent.KEYCODE_V: { DvrManager dvrManager = TvApplication.getSingletons(this).getDvrManager(); long startTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(5); long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(35); dvrManager.addSchedule(getCurrentChannel(), startTime, endTime); return true; } case KeyEvent.KEYCODE_PROG_BLUE: case KeyEvent.KEYCODE_BUTTON_X: case KeyEvent.KEYCODE_X: { if (CommonFeatures.DVR.isEnabled(this)) { Channel channel = mTvView.getCurrentChannel(); long channelId = channel.getId(); Program p = mProgramDataManager.getCurrentProgram(channelId); if (p == null) { long now = System.currentTimeMillis(); mDvrManager.addSchedule(channel, now, now + TimeUnit.MINUTES.toMillis(1)); } else { mDvrManager.addSchedule(p, mDvrManager.getScheduledRecordingsThatConflict(p)); } return true; } } case KeyEvent.KEYCODE_PROG_YELLOW: case KeyEvent.KEYCODE_BUTTON_Y: case KeyEvent.KEYCODE_Y: { if (CommonFeatures.DVR.isEnabled(this) && BuildCompat.isAtLeastN()) { // TODO(DVR) only get finished recordings. List<RecordedProgram> recordedPrograms = mDvrDataManager.getRecordedPrograms(); Log.d(TAG, "Found " + recordedPrograms.size() + " recordings"); if (recordedPrograms.isEmpty()) { Toast.makeText(this, "No finished recording to play", Toast.LENGTH_LONG).show(); } else { RecordedProgram r = recordedPrograms.get(0); Intent intent = new Intent(this, DvrPlayActivity.class); intent.putExtra(ScheduledRecording.RECORDING_ID_EXTRA, r.getId()); startActivity(intent); } return true; } } } } return super.onKeyUp(keyCode, event); }