mediaPlayer and back button
<p>I have an activity that implements <code>MediaController.MediaPlayerControl</code>.</p>

<p>The audio player plays the file just fine, but I can not get out of the activity by pressing the back button.</p>

<p>When the back button is pressed, I get these 2 messages in the log. The current activity appears to continue to work just fine.</p>

<pre><code>WARN/KeyCharacterMap(522): No keyboard for id 0
WARN/KeyCharacterMap(522): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
</code></pre>

<p>If I take the implementation of MediaController.MediaPlayercontrol out of the activity, the back button works as expected.</p>

<p>Any ideas on how to resolve this?</p>

<p>Here is my class.  I took the irrelevant parts out so hopefully I didn't screw the copy up.</p>

<pre><code>public class ContentActivity extends Activity implements OnPreparedListener, MediaController.MediaPlayerControl {

private static final String TAG = "AudioPlayer";
private MediaPlayer mediaPlayer;
private MediaController mediaController;
private String audioFile;
private Handler handler = new Handler();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.content);


audioFile = "http://example.com/foo.mp3"
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(this);

mediaController = new MediaController(this){
     @Override
     public void hide() {
         this.show(0);
     }

     @Override
     public void setMediaPlayer(MediaPlayerControl player) {
         super.setMediaPlayer(player);
         this.show();
     }
 };

mediaPlayer.setDataSource(audioFile);
mediaPlayer.prepare();
}

@Override
protected void onStop() {
super.onStop();
mediaPlayer.stop();
mediaPlayer.release();
}

//--MediaPlayerControl methods----------------------------------------------------
public void start() {
  mediaPlayer.start();
}

public void pause() {
  mediaPlayer.pause();
}

public int getDuration() {
  return mediaPlayer.getDuration();
}

public int getCurrentPosition() {
  return mediaPlayer.getCurrentPosition();
}

public void seekTo(int i) {
  mediaPlayer.seekTo(i);
}

public boolean isPlaying() {
  return mediaPlayer.isPlaying();
}

public int getBufferPercentage() {
  return 0;
}

public boolean canPause() {
  return true;
}

public boolean canSeekBackward() {
  return true;
}

public boolean canSeekForward() {
  return true;
}
//--------------------------------------------------------------------------------
public void onPrepared(MediaPlayer mediaPlayer) {
    Log.d(TAG, "onPrepared");
    mediaController.setMediaPlayer(this);
    mediaController.setAnchorView(findViewById(R.id.mediaController));

    handler.post(new Runnable() {
      public void run() {
        mediaController.setEnabled(true);
        mediaController.show();
      }
    });
}}
</code></pre>

<p>Stack</p>

<pre><code>    ----- pid 632 at 2011-07-21 13:53:37 -----

DALVIK THREADS:
"main" prio=5 tid=3 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x4001b268 self=0xbd00
  | sysTid=632 nice=0 sched=0/0 cgrp=default handle=-1344001384
  at android.os.BinderProxy.transact(Native Method)
  at android.app.ActivityManagerProxy.handleApplicationError(ActivityManagerNative.java:2358)
  at com.android.internal.os.RuntimeInit.crash(RuntimeInit.java:339)
  at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)
  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:887)
  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:884)
  at dalvik.system.NativeStart.main(Native Method)

"Binder Thread #4" prio=5 tid=17 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44cd5370 self=0x3d6878
  | sysTid=648 nice=0 sched=0/0 cgrp=default handle=3645656
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #3" prio=5 tid=15 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44cd52b0 self=0x3d5ca8
  | sysTid=647 nice=0 sched=0/0 cgrp=default handle=4013152
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #2" prio=5 tid=13 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44c03da0 self=0x137be8
  | sysTid=637 nice=0 sched=0/0 cgrp=default handle=1281760
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=11 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x44c00a48 self=0x12def8
  | sysTid=636 nice=0 sched=0/0 cgrp=default handle=1159488
  at dalvik.system.NativeStart.run(Native Method)

"JDWP" daemon prio=5 tid=9 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x44bfe2a0 self=0x138d18
  | sysTid=635 nice=0 sched=0/0 cgrp=default handle=1193192
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=7 RUNNABLE
  | group="system" sCount=0 dsCount=0 s=N obj=0x44bfe1e8 self=0x1233b0
  | sysTid=634 nice=0 sched=0/0 cgrp=default handle=1239344
  at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=5 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x436a13f8 self=0x118bc8
  | sysTid=633 nice=0 sched=0/0 cgrp=default handle=1163392
  at dalvik.system.NativeStart.run(Native Method)

----- end 632 -----
</code></pre>
