I am trying to use a MediaController and alter it so that it does not disappear after 3 seconds. I have found this code in a related question and I am using it:
mediaController = new MediaController(this) {
@Override
public void hide()
{
mediaController.show();
}
};
This code works, but when the activity stops (from using back button), I get log errors about a leaked window from a view added in the code below at the show(0) statement:
public void onPrepared(MediaPlayer mediaPlayer) {
mediaController.setMediaPlayer(this);
mediaController.setAnchorView(findViewById(R.id.audio_control));
handler.post(new Runnable() {
public void run() {
mediaController.setEnabled(true);
mediaController.show(0);
}
});
}
It seems to me that overriding the hide method by simply calling the show method means the hide method is not doing what is needed when finishing the activity. I must be overriding other necessary functionality, like actually hiding the controller!
I want to hide the controller when necessary (such as when finishing with it), but not in the case of when it is simply being hidden after 3 seconds (and the activity is not being finished).
Or maybe I should let the controller disappear after 3 seconds all the time but I am not sure I understand why it is implemented this way. It seems better to just keep it there all the time to me.