I am having two activities A and B. when i click the button in A that will shows B. when i click the Button in B it backs to A. i had set the overridePendingTransition metho
I use this code on an activity with a media player. I needed to stop the playback when user pressed the back button but still be able to go back to previous activity.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
try{
mp.stop(); //this line stops the player
return super.onKeyDown(keyCode, event);//this line does the rest
}
catch(IllegalStateException e){
e.printStackTrace();
}
return true;
}
return super.onKeyDown(keyCode, event); //handles other keys
}