I'm trying to override Back button to stop an audio player and close media player activity, but I noticed that volume buttons are not working anymore. I imagine there is a mistake in overriding code. PS. in my MediaController
I override hide()
method to always show controls.
mediaController = new MediaController(this)
{
@Override
public void hide() {
// TODO Auto-generated method stub
//do nothing
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (mediaPlayer != null) {
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer = null;
}
super.hide();
Activity a = (Activity)getContext();
a.finish();
}
return true;
}
};