MediaPlayer 在华为手机上的内存泄漏问题

MediaPlayer  在华为手机上播放15个音频,在往下播放就没有声音了,会出现

W/MediaPlayer: mediaplayer went away with unhandled events
I/MediaPlayer: [HSM] stayAwake false uid: 10256, pid: 15895
I/MediaPlayer: [HSM] stayAwake false uid: 10256, pid: 15895
I/MediaPlayer: Pid:15895 MediaPlayer destructor
I/MediaPlayer: [HSM] stayAwake false uid: 10256, pid: 15895
I/MediaPlayer: setDataSource(http://xxx/upload/app/question/b89a9d6c-09e4-471e-84b7-99fa5cf44991.mp3)
I/MediaPlayer: [HSM] stayAwake true uid: 10256, pid: 15895
I/MediaPlayer: Pid:15895 MediaPlayer::start

即使每次播放前都  mediaPlayer = new MediaPlayer();  也不行

解决办法:

/**
 * 释放播放器资源
 */
private void ReleasePlayer() {
    if (mediaPlayer != null) {
        mediaPlayer.stop();
        mediaPlayer.release();
        mediaPlayer = null;
    }
}

参考http://blog.csdn.net/sdfdzx/article/details/60144834

你可能感兴趣的:(Android)