Example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN

List of usage examples for android.view KeyEvent KEYCODE_VOLUME_DOWN

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Prototype

int KEYCODE_VOLUME_DOWN

To view the source code for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Click Source Link

Document

Key code constant: Volume Down key.

Usage

From source file:com.microsoft.mimickeralarm.appcore.AlarmMainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_LOWER,
                AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_RAISE,
                AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
    } else {/*www .j  a  v a  2 s  .  c o  m*/
        return super.onKeyDown(keyCode, event);
    }
    return true;
}

From source file:com.grass.caishi.cc.activity.main.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    super.onKeyUp(keyCode, event);
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        this.hideNavigationBar();
    }//from   www.  j a  v  a  2s  .co m
    return false;
}

From source file:org.apache.cordova.X5CoreAndroid.java

/**
 * Override the default behavior of the Android volume buttons.
 * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript event will be fired.
 *
 * @param button        volumeup, volumedown
 * @param override      T=override, F=cancel override
 *///from w  w w.j  a  va  2 s .  com
public void overrideButton(String button, boolean override) {
    LOG.i("App",
            "WARNING: Volume Button Default Behavior will be overridden.  The volume event will be fired!");
    if (button.equals("volumeup")) {
        webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, override);
    } else if (button.equals("volumedown")) {
        webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, override);
    } else if (button.equals("menubutton")) {
        webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_MENU, override);
    }
}

From source file:de.pixart.messenger.ui.ScanActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // don't launch camera app
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
        cameraHandler.post(() -> cameraManager.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP));
        return true;
    }//ww  w.ja v a  2 s  . c om

    return super.onKeyDown(keyCode, event);
}

From source file:com.neuron.fantecremote.FantecActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        return true;
    }/*from  w w  w .j a  va 2  s  . co  m*/
    return super.onKeyUp(keyCode, event);
}

From source file:lenidh.android.holochron.ui.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        this.onVolumeDown();
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        this.onVolumeUp();
        return true;
    }//  w  ww  .  j a va2s.  com

    return super.onKeyDown(keyCode, event);
}

From source file:zxing.util.CaptureActivity.java

License:asdf

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        Intent intent = new Intent();
        if (lastResult != null) {
            intent.putExtra("BarCode", lastResult);
            setResult(RESULT_OK, intent);
            finish();//ww w  . j a  v  a  2 s.c  o  m
            return true;
        } else {
            restartPreviewAfterDelay(0L);
            return true;
        }
        //         if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK)
        //               && lastResult != null) {
        //            restartPreviewAfterDelay(0L);
        //            return true;
        //         }
        //         break;
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    // Use volume up/down to turn on light
    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);
}

From source file:freed.cam.ActivityFreeDcamMain.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (activityIsResumed) {
        Log.d(TAG, "KeyCode Pressed:" + keyCode);
        int appSettingsKeyShutter = 0;

        if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER).equals(StringUtils.VoLP))
            appSettingsKeyShutter = KeyEvent.KEYCODE_VOLUME_UP;
        else if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER)
                .equals(StringUtils.VoLM))
            appSettingsKeyShutter = KeyEvent.KEYCODE_VOLUME_DOWN;
        else if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER)
                .equals(StringUtils.Hook)
                || getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER).equals(""))
            appSettingsKeyShutter = KeyEvent.KEYCODE_HEADSETHOOK;

        if (keyCode == KeyEvent.KEYCODE_3D_MODE || keyCode == KeyEvent.KEYCODE_POWER
                || keyCode == appSettingsKeyShutter || keyCode == KeyEvent.KEYCODE_UNKNOWN
                || keyCode == KeyEvent.KEYCODE_CAMERA) {
            cameraFragment.GetModuleHandler().DoWork();
            return true;
        }/*w w  w.j a v a 2s .c  o m*/
        if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) {
            closeActivity();
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        // capture event to suppress android system sound
        return true;
    }/* w  w w. j a  v a  2 s.c o m*/
    return super.onKeyUp(keyCode, event);
}

From source file:org.madmatrix.zxing.android.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK: // ?
        if ((source == IntentSource.NONE) && lastResult != null) {
            restartPreviewAfterDelay(0L);
            return true;
        }/*from   w  ww  .j a  va  2  s .  c  o  m*/
        break;
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    // Use volume up/down to turn on light
    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);
}