本文整理汇总了Java中android.view.KeyEvent.KEYCODE_VOLUME_UP属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_VOLUME_UP属性的具体用法?Java KeyEvent.KEYCODE_VOLUME_UP怎么用?Java KeyEvent.KEYCODE_VOLUME_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_VOLUME_UP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
// Don't allow this value to go to 0. It shuts the screen off.
if (minBrightness > 1) {
minBrightness -= 1;
updateDisplay();
Util.setActivityBrightness(getWindow(), minBrightness);
}
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
if (minBrightness < 255) {
minBrightness += 1;
updateDisplay();
Util.setActivityBrightness(getWindow(), minBrightness);
}
return true;
default:
return super.onKeyDown(keyCode, event);
}
}
示例2: setButtonPlumbedToJs
@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
// TODO: Why are search and menu buttons handled separately?
if (override) {
boundKeyCodes.add(keyCode);
} else {
boundKeyCodes.remove(keyCode);
}
return;
default:
throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
}
}
示例3: handleVolumeKeyEvent
/**
* Modify remote volume by handling volume keys.
*
* @param controller The remote controller through which the volume will be modified.
* @param event The key event. Its keycode needs to be either {@code KEYCODE_VOLUME_DOWN} or
* {@code KEYCODE_VOLUME_UP} otherwise this method will return false.
* @return True if the event is handled.
*/
private boolean handleVolumeKeyEvent(MediaRouteController controller, KeyEvent event) {
if (!controller.isBeingCast()) return false;
int action = event.getAction();
int keyCode = event.getKeyCode();
// Intercept the volume keys to affect only remote volume.
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) controller.setRemoteVolume(-1);
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_DOWN) controller.setRemoteVolume(1);
return true;
default:
return false;
}
}
示例4: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//call on back button
onBackPressed();
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && !AppPreference.isVolumeKeyNavigation()) {
//volume down
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 1);
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && !AppPreference.isVolumeKeyNavigation()) {
//volume up
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 1);
}
return true;
}
示例5: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if ((keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_UP)
|| mVideoInfo.state == PlayerState.FINISHED) {
return super.dispatchKeyEvent(event);
}
return handleVolumeKeyEvent(mMediaRouteController, event);
}
示例6: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
keyCode != KeyEvent.KEYCODE_MENU &&
keyCode != KeyEvent.KEYCODE_CALL &&
keyCode != KeyEvent.KEYCODE_ENDCALL;
if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
if (mMediaPlayer.isPlaying()) {
pause();
mMediaController.show();
} else {
start();
mMediaController.hide();
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
if (!mMediaPlayer.isPlaying()) {
start();
mMediaController.hide();
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
|| keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
if (mMediaPlayer.isPlaying()) {
pause();
mMediaController.show();
}
return true;
} else {
toggleMediaControlsVisiblity();
}
}
return super.onKeyDown(keyCode, event);
}
示例7: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
keyCode != KeyEvent.KEYCODE_MENU &&
keyCode != KeyEvent.KEYCODE_CALL &&
keyCode != KeyEvent.KEYCODE_ENDCALL;
if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
if (mMediaPlayer.isPlaying()) {
pause();
mMediaController.show();
} else {
start();
mMediaController.hide();
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
if (!mMediaPlayer.isPlaying()) {
start();
mMediaController.hide();
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
|| keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
if (mMediaPlayer.isPlaying()) {
pause();
mMediaController.show();
}
return true;
} else {
toggleMediaControlsVisibility();
}
}
return super.onKeyDown(keyCode, event);
}
示例8: handleVolumeKey
/**
* 处理音量键,避免外部按音量键后导航栏和状态栏显示出来退不回去的状态
*
* @param keyCode
* @return
*/
public boolean handleVolumeKey(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
_setVolume(true);
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
_setVolume(false);
return true;
} else {
return false;
}
}
示例9: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
//关闭灯光
cameraManager.setTorch(false);
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
//开启闪光灯
cameraManager.setTorch(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
示例10: checkVolumeKeys
public boolean checkVolumeKeys(int keyCode) {
if (ignoreVolumeEnabled && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
return true;
} else {
return false;
}
}
示例11: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// Handle volume key usage for navigation
if (mSettings.useVolumeKeysForNavigation() && mPresenterVisible) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
onNextSlide();
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
onPrevSlide();
return true;
}
}
return super.onKeyUp(keyCode, event);
}
示例12: beforeHookedMethod
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!allowSkipTrack) return;
final KeyEvent event = (KeyEvent) param.args[0];
final int keyCode = event.getKeyCode();
initManagers((Context) XposedHelpers.getObjectField(param.thisObject, "mContext"));
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP) &&
(event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) != 0 &&
!mPowerManager.isInteractive() &&
mAudioManager != null && mAudioManager.isMusicActive()) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
mIsLongPress = false;
handleVolumeLongPress(param.thisObject, keyCode);
} else {
handleVolumeLongPressAbort(param.thisObject);
if (!mIsLongPress) {
if (mShoudTriggerWakeUp) {
wakeUp();
} else {
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
keyCode == KeyEvent.KEYCODE_VOLUME_UP ?
AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, 0);
}
}
}
param.setResult(0);
return;
}
}
示例13: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//call on back button
onBackPressed();
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && !AppPreference.isVolumeKeyNavigation()) {
//volume down
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 1);
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && !AppPreference.isVolumeKeyNavigation()) {
//volume up
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 1);
}
return true;
}
示例14: onKeyDown
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
debug = !debug;
onSetDebug(debug);
requestRender();
return true;
}
return super.onKeyDown(keyCode, event);
}
示例15: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d(THIS_FILE, "Key down : " + keyCode);
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
case KeyEvent.KEYCODE_VOLUME_UP:
//
// Volume has been adjusted by the user.
//
Log.d(THIS_FILE, "onKeyDown: Volume button pressed");
int action = AudioManager.ADJUST_RAISE;
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
action = AudioManager.ADJUST_LOWER;
}
// Detect if ringing
SipCallSession currentCallInfo = getActiveCallInfo();
// If not any active call active
if (currentCallInfo == null && serviceConnected) {
break;
}
if (service != null) {
try {
service.adjustVolume(currentCallInfo, action, AudioManager.FLAG_SHOW_UI);
} catch (RemoteException e) {
Log.e(THIS_FILE, "Can't adjust volume", e);
}
}
return true;
case KeyEvent.KEYCODE_CALL:
case KeyEvent.KEYCODE_ENDCALL:
return inCallAnswerControls.onKeyDown(keyCode, event);
case KeyEvent.KEYCODE_SEARCH:
// Prevent search
return true;
default:
// Nothing to do
}
return super.onKeyDown(keyCode, event);
}