本文整理汇总了Java中android.view.KeyEvent.ACTION_UP属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.ACTION_UP属性的具体用法?Java KeyEvent.ACTION_UP怎么用?Java KeyEvent.ACTION_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.ACTION_UP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// To intercept hardware key, a view must have focus.
if (mDelegate == null) return super.dispatchKeyEvent(event);
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
KeyEvent.DispatcherState state = getKeyDispatcherState();
if (state != null) {
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
state.startTracking(event, this);
return true;
} else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()
&& state.isTracking(event)) {
onBackPressed();
return true;
}
}
}
return super.dispatchKeyEvent(event);
}
示例2: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if(event.getAction() == KeyEvent.ACTION_DOWN)
{
switch(event.getKeyCode())
{
case KeyEvent.KEYCODE_BACK:
mBackKeyDown = true;
return true;
default:
mBackKeyDown = false;
break;
}
}
if(event.getAction() == KeyEvent.ACTION_UP)
{
switch(event.getKeyCode())
{
case KeyEvent.KEYCODE_BACK:
if(mBackKeyDown)
{
mBackKeyDown = false;
finish();
}
return true;
default:
mBackKeyDown = false;
break;
}
}
return super.dispatchKeyEvent(event);
}
示例3: dispatchKeyEventPreIme
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
return delegate != null && delegate.onPreIme() || super.dispatchKeyEventPreIme(event);
}
return super.dispatchKeyEventPreIme(event);
}
示例4: onKeyPreIme
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
if (mOnImeBack != null) mOnImeBack.onImeBack(this, this.getText().toString());
}
return super.dispatchKeyEvent(event);
}
示例5: dispatchKeyEvent
/**
* Called to process key events. You can override this to intercept all
* key events before they are dispatched to the window. Be sure to call
* this implementation for key events that should be handled normally.
*
* @param event The key event.
*
* @return boolean Return true if this event was consumed.
*/
public boolean dispatchKeyEvent(KeyEvent event) {
onUserInteraction();
// Let action bars open menus in response to the menu key prioritized over
// the window handling it
final int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_MENU &&
mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
return true;
} else if (event.isCtrlPressed() &&
event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
// Capture the Control-< and send focus to the ActionBar
final int action = event.getAction();
if (action == KeyEvent.ACTION_DOWN) {
final ActionBar actionBar = getActionBar();
if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
mEatKeyUpEvent = true;
return true;
}
} else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
mEatKeyUpEvent = false;
return true;
}
}
Window win = getWindow();
if (win.superDispatchKeyEvent(event)) {
return true;
}
View decor = mDecor;
if (decor == null) decor = win.getDecorView();
return event.dispatch(this, decor != null
? decor.getKeyDispatcherState() : null, this);
}
示例6: onKeyPreIme
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
onEditorAction(-1);
dispatchKeyEvent(event);
return false;
}
return super.onKeyPreIme(keyCode, event);
}
示例7: onKeyPreIme
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK &&
event.getAction() == KeyEvent.ACTION_UP) {
if (mOnImeBack != null)
mOnImeBack.onImeBack(this, this.getText().toString());
}
return super.dispatchKeyEvent(event);
}
示例8: dispatchKeyEventPreIme
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (isMenuOpen()
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
&& event.getAction() == KeyEvent.ACTION_UP
&& event.getRepeatCount() == 0) {
closeMenu();
return true;
}
return super.dispatchKeyEventPreIme(event);
}
示例9: onKey
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (keyEvent.getAction() == KeyEvent.ACTION_UP
&& keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
tryMount();
return true;
}
return false;
}
示例10: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
final int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
removeAllCallbacks();
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_UP:
if (!mHasSelectorWheel) {
break;
}
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
if (mWrapSelectorWheel || ((keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
? getValue() < getMaxValue() : getValue() > getMinValue())) {
requestFocus();
mLastHandledDownDpadKeyCode = keyCode;
removeAllCallbacks();
if (mFlingScroller.isFinished()) {
changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
}
return true;
}
break;
case KeyEvent.ACTION_UP:
if (mLastHandledDownDpadKeyCode == keyCode) {
mLastHandledDownDpadKeyCode = -1;
return true;
}
break;
}
}
return super.dispatchKeyEvent(event);
}
示例11: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
mBackDown = true;
return true;
case KeyEvent.KEYCODE_HOME:
mHomeDown = true;
return true;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (!event.isCanceled()) {
// Do BACK behavior.
}
mBackDown = true;
return true;
case KeyEvent.KEYCODE_HOME:
if (!event.isCanceled()) {
// Do HOME behavior.
}
mHomeDown = true;
return true;
}
}
return super.dispatchKeyEvent(event);
}
示例12: onDispatchKeyEvent
@Override
public Boolean onDispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
boolean isBackButton = keyCode == KeyEvent.KEYCODE_BACK;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (isBackButton && mCustomView != null) {
return true;
} else if (boundKeyCodes.contains(keyCode)) {
return true;
} else if (isBackButton) {
return engine.canGoBack();
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (isBackButton && mCustomView != null) {
hideCustomView();
return true;
} else if (boundKeyCodes.contains(keyCode)) {
String eventName = null;
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
eventName = "volumedownbutton";
break;
case KeyEvent.KEYCODE_VOLUME_UP:
eventName = "volumeupbutton";
break;
case KeyEvent.KEYCODE_SEARCH:
eventName = "searchbutton";
break;
case KeyEvent.KEYCODE_MENU:
eventName = "menubutton";
break;
case KeyEvent.KEYCODE_BACK:
eventName = "backbutton";
break;
}
if (eventName != null) {
sendJavascriptEvent(eventName);
return true;
}
} else if (isBackButton) {
return engine.goBack();
}
}
return null;
}
示例13: onReceive
@Override
public void onReceive(final Context context, final Intent intent) {
LogUtils.i(TAG, "Received intent: " + intent);
final String intentAction = intent.getAction();
if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intentAction)) {
startService(context, MusicServiceConstants.CMDPAUSE, System.currentTimeMillis());
} else if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) {
final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if (event == null || event.getAction() != KeyEvent.ACTION_UP) {
return;
}
String command = null;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_HEADSETHOOK:
command = MusicServiceConstants.CMDHEADSETHOOK;
break;
case KeyEvent.KEYCODE_MEDIA_STOP:
command = MusicServiceConstants.CMDSTOP;
break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
command = MusicServiceConstants.CMDTOGGLEPAUSE;
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
command = MusicServiceConstants.CMDNEXT;
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
command = MusicServiceConstants.CMDPREVIOUS;
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
command = MusicServiceConstants.CMDPAUSE;
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicServiceConstants.CMDPLAY;
break;
}
if (command != null) {
startService(context, command, event.getEventTime());
if (isOrderedBroadcast()) {
abortBroadcast();
}
}
}
}
示例14: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if(event.getAction() == KeyEvent.ACTION_DOWN)
{
switch(event.getKeyCode())
{
case KeyEvent.KEYCODE_MENU:
myOpenMenu();
return true;
case KeyEvent.KEYCODE_BACK:
mBackKeyDown = true;
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
if(edit.getSelectionStart() == 0 && edit.getSelectionEnd() == 0)
{
closeFile();
return true;
}
default:
mBackKeyDown = false;
break;
}
}
if(event.getAction() == KeyEvent.ACTION_UP)
{
switch(event.getKeyCode())
{
case KeyEvent.KEYCODE_BACK:
if(mBackKeyDown)
{
mBackKeyDown = false;
closeFile();
return true;
}
else
{
mBackKeyDown = false;
}
default:
mBackKeyDown = false;
break;
}
}
return super.dispatchKeyEvent(event);
}
示例15: onReceive
@Override
public void onReceive(Context context, Intent intent) {
KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if (event == null || event.getAction() != KeyEvent.ACTION_UP) {
return;
}
IPlayControl control = MainActivity.getControl();
if (control == null) {
return;
}
try {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_MEDIA_PLAY:
case KeyEvent.KEYCODE_MEDIA_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_HEADSETHOOK:
// 暂停
if (control.status() == PlayController.STATUS_PLAYING) {
control.pause();
} else {
control.resume();
}
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
// 下一曲
control.next();
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
// 上一曲
control.pre();
break;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}