I am using the volume up/down buttons to navigate in an activity. This works fine but i cannot use the volume down button to start the next activity. Also the volume is simultaneously increased/reduced. Here is the code
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_VOLUME_DOWN:
event.startTracking();
//navigation
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
//navigation
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
startActivity(new Intent("com.example.fittle.FISH"));
return true;
}
return super.onKeyLongPress(keyCode, event);
}