Using the code below, I stopped using the volume buttons if I donβt transmit sound (otherwise it annoyingly changes the ringer volume), but the back button does not work.
Pressing "back" should get to my phone desktop (or exit my application, as expected), but it does nothing. If I open the menu, Back will close the menu as it should, but I cannot leave the application.
I copied the code to other actions in my application, if I open another action in my application, because the "Back" button does not work, I can not return to the main screen :)
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { //Suppress the use of the volume keys unless we are currently listening to the stream if(keyCode==KeyEvent.KEYCODE_VOLUME_UP) { if(StreamService.INT_PLAY_STATE==0){ return true; }else{ return false; } } if(keyCode==KeyEvent.KEYCODE_VOLUME_DOWN) { if(StreamService.INT_PLAY_STATE==0){ return true; }else{ return false; } } return false;
Why is this happening?
android override back volume android-audiomanager
jwbensley
source share