Example usage for android.view KeyEvent KEYCODE_VOLUME_UP

List of usage examples for android.view KeyEvent KEYCODE_VOLUME_UP

Introduction

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

Prototype

int KEYCODE_VOLUME_UP

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

Click Source Link

Document

Key code constant: Volume Up key.

Usage

From source file:au.id.tedp.mapdroid.Picker.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    OSMMapView map = (OSMMapView) findViewById(R.id.mapView);
    int change = 0;

    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
        change = -1;//from  w  w w  .ja v  a2  s . co m
    else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
        change = +1;

    if (change != 0) {
        map.setZoom(map.getZoom() + change);
        return true;
    }

    // Propagate to the default implementation to get regular back-button
    // behavior.
    return super.onKeyDown(keyCode, event);
}

From source file:eu.geekgasm.kintrol.DeviceControlActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_DOWN) {
            kontrollerThread.increaseVolume();
        }/*from w w  w  .java  2 s  . co m*/
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            kontrollerThread.decreaseVolume();
        }
        return true;
    default:
        return super.dispatchKeyEvent(event);
    }
}

From source file:com.firefly.sample.castcompanionlibrary.cast.player.VideoCastControllerActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        onVolumeChange((double) mVolumeIncrement);
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        onVolumeChange(-(double) mVolumeIncrement);
    } else {//from  w w  w. jav a 2  s  .c o m
        return super.onKeyDown(keyCode, event);
    }
    return true;
}

From source file:io.github.hidroh.materialistic.KeyDelegate.java

/**
 * Calls from {@link Activity#onKeyLongPress(int, KeyEvent)} to delegate
 * @param keyCode    event key code/* ww w .  ja  va2 s.  co m*/
 * @param event      key event
 * @return  true if is intercepted as navigation, false otherwise
 */
@SuppressWarnings("UnusedParameters")
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    if (!mEnabled) {
        return false;
    }
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        longPress(DIRECTION_UP);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        longPress(DIRECTION_DOWN);
        return true;
    }
    return false;
}

From source file:de.qspool.clementineremote.ui.Player.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        // Control the volume of clementine if enabled in the options
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (mSharedPref.getBoolean(App.SP_KEY_USE_VOLUMEKEYS, true)) {
                Message msgDown = Message.obtain();
                msgDown.obj = new RequestVolume(App.mClementine.getVolume() - 10);
                App.mClementineConnection.mHandler.sendMessage(msgDown);
                return true;
            }/*  w  w  w  .  ja v a 2s.  co m*/
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (mSharedPref.getBoolean(App.SP_KEY_USE_VOLUMEKEYS, true)) {
                Message msgUp = Message.obtain();
                msgUp.obj = new RequestVolume(App.mClementine.getVolume() + 10);
                App.mClementineConnection.mHandler.sendMessage(msgUp);
                return true;
            }
            break;
        default:
            break;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.bluros.music.activities.BaseActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        return MusicPlayer.volumeKeyAction(false);
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        return MusicPlayer.volumeKeyAction(true);
    }/*  w w w. j  av  a2  s  . co m*/
    return super.onKeyDown(keyCode, event);
}

From source file:com.syncedsynapse.kore2.ui.RemoteActivity.java

/**
 * Override hardware volume keys and send to Kodi
 *//*from   w w w .  j av  a  2 s .c  o  m*/
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    // Check whether we should intercept this
    boolean useVolumeKeys = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
            Settings.KEY_PREF_USE_HARDWARE_VOLUME_KEYS, Settings.DEFAULT_PREF_USE_HARDWARE_VOLUME_KEYS);
    if (useVolumeKeys) {
        int action = event.getAction();
        int keyCode = event.getKeyCode();
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (action == KeyEvent.ACTION_DOWN) {
                new Application.SetVolume(GlobalType.IncrementDecrement.INCREMENT)
                        .execute(hostManager.getConnection(), null, null);
            }
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (action == KeyEvent.ACTION_DOWN) {
                new Application.SetVolume(GlobalType.IncrementDecrement.DECREMENT)
                        .execute(hostManager.getConnection(), null, null);
            }
            return true;
        }
    }

    return super.dispatchKeyEvent(event);
}

From source file:com.coinomi.wallet.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(new Runnable() {
            @Override//from   w  w w . ja  v a 2s. co m
            public void run() {
                cameraManager.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP);
            }
        });
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.audiokernel.euphonyrmt.library.SimpleLibraryActivity.java

@Override
public boolean onKeyLongPress(final int keyCode, final KeyEvent event) {
    boolean result = true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        MPDControl.run(MPDControl.ACTION_NEXT);
        break;//from  ww w.ja  va 2s . c  om
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        MPDControl.run(MPDControl.ACTION_PREVIOUS);
        break;
    default:
        result = super.onKeyLongPress(keyCode, event);
        break;
    }

    return result;
}

From source file:com.google.android.car.kitchensink.volume.VolumeTestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.volume_test, container, false);

    mVolumeList = (ListView) v.findViewById(R.id.volume_list);
    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);

    mRefreshButton = (Button) v.findViewById(R.id.refresh);
    mAdapter = new VolumeAdapter(getContext(), R.layout.volume_item, mVolumeInfos, this);
    mVolumeList.setAdapter(mAdapter);//from   w w w  .  ja va  2s  .  co  m

    mRefreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            initVolumeInfo();
        }
    });

    mCarEmulator = CarEmulator.create(getContext());
    mCar = mCarEmulator.getCar();
    try {
        mCarAudioManager = (CarAudioManager) mCar.getCarManager(Car.AUDIO_SERVICE);
        initVolumeInfo();
        mCarAudioManager.setVolumeController(mVolumeController);
    } catch (CarNotConnectedException e) {
        throw new RuntimeException(e); // Should never occur in car emulator.
    }

    mVolumeUp = (Button) v.findViewById(R.id.volume_up);
    mVolumeDown = (Button) v.findViewById(R.id.volume_down);

    mVolumeUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCarEmulator.injectKey(KeyEvent.KEYCODE_VOLUME_UP);
        }
    });

    mVolumeDown.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCarEmulator.injectKey(KeyEvent.KEYCODE_VOLUME_DOWN);
        }
    });

    return v;
}