当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.KEYCODE_VOLUME_UP属性代码示例

本文整理汇总了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);
  }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:22,代码来源:CalibrateActivity.java

示例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);
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:18,代码来源:CordovaWebViewImpl.java

示例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;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:ExpandedControllerActivity.java

示例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;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:16,代码来源:QuranPageReadActivity.java

示例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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:ExpandedControllerActivity.java

示例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);
}
 
开发者ID:wheat7,项目名称:VRPlayer,代码行数:39,代码来源:PlayerView.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:IjkVideoView.java

示例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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:IjkPlayerView.java

示例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);
}
 
开发者ID:MRYangY,项目名称:YZxing,代码行数:14,代码来源:ScannerActivity.java

示例10: checkVolumeKeys

public boolean checkVolumeKeys(int keyCode) {
    if (ignoreVolumeEnabled && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:7,代码来源:AppRunnerActivity.java

示例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);
}
 
开发者ID:FelixWohlfrom,项目名称:Presenter-Client-Android,代码行数:14,代码来源:BluetoothConnector.java

示例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;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:31,代码来源:ModVolumeKeySkipTrack.java

示例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;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:15,代码来源:QuranPageReadActivity.java

示例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);
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:9,代码来源:CameraActivity.java

示例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);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:42,代码来源:InCallActivity.java


注:本文中的android.view.KeyEvent.KEYCODE_VOLUME_UP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。