當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。