Android back button and MediaController

Based on the source code, this should work:

  1. Extend MediaController (for the purposes of this answer, call it RonnieMediaController)
  2. Override dispatchKeyEvent() in RonnieMediaController
  3. Before chaining to the superclass, check for KeyEvent.KEYCODE_BACK, and if that is encountered, tell your activity to finish()
  4. Use RonnieMediaController instead of MediaController with your VideoView

Personally, I’d just leave it alone, as with this change your user cannot make a RonnieMediaController disappear on demand.

Leave a Comment