2012-01-17 2 views
2

MediaPlayer 액티비티가 있습니다. 자세한 LogCat 출력을 알아 채고 계속해서 반복되는 것을 보았을 때까지 작업을 마쳤다고 생각했습니다.MediaPlayer를 제대로 닫으십시오.

01-17 17:03:50.466: D/StatusBarPolicy(209): iconIndex=1 
01-17 17:03:50.476: V/StatusBarPolicy(209): cdmaLevel:1;max:4 
01-17 17:03:50.476: D/StatusBarPolicy(209): iconLevel:1 
01-17 17:03:50.476: D/StatusBarService(209): updateIcon slot=phone_signal index=20 viewIndex=14 old=StatusBarIcon(pkg=com.android.systemui id=0x7f020007 level=0 visible=true num=0) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020008 level=0 visible=true num=0) 
01-17 17:03:50.597: V/MediaPlayer(16768): getCurrentPosition 
01-17 17:03:50.597: V/MediaPlayerService(82): getCurrentPosition 
01-17 17:03:50.597: V/MediaPlayerService(82): [261] getCurrentPosition = 277943 
01-17 17:03:50.597: V/MediaPlayerService(82): [261] isPlaying: 0 
01-17 17:03:50.597: V/MediaPlayer(16768): isPlaying: 0 
01-17 17:03:50.597: V/MediaPlayerService(82): [261] isPlaying: 0 
01-17 17:03:50.597: V/MediaPlayer(16768): isPlaying: 0 
01-17 17:03:50.847: V/MediaPlayer(16768): getCurrentPosition 
01-17 17:03:50.847: V/MediaPlayerService(82): getCurrentPosition 
01-17 17:03:50.847: V/MediaPlayerService(82): [261] getCurrentPosition = 277943' 

이렇게하면 내 활동이 제대로 닫히지 않을 것 같습니다. 나는 그것을 위해 사용하고 코드는 앞의 코드는 사용자가 앱을 완전히 종료 후에도 반복 유지

cancelButton.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View v) { 
      new AlertDialog.Builder(CastrRecorder.this) 
      .setTitle("Close") 
      .setMessage("Any unsaved changes will be lost. Continue?") 
      .setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        Log.d("AlertDialog", "Positive"); 
        mPlayer.stop(); 
        mPlayer.release(); 
        Intent baseIntent = new Intent(Recorder.this, Activity.class); 
        Recorder.this.startActivity(baseIntent); 
       } 
      }) 
      .setNegativeButton("No", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        Log.d("AlertDialog", "Negative"); 
       } 
      }) 
      .show(); 
     } 
    }); 

입니다. 나는 도울 수 없지만 그것이 나쁠 것이라고 생각합니다. 이것을 막기 위해 무엇을 할 수 있습니까?

답변

2

이것이 중요한지 확실하지 않지만 stop()과 release() 사이에서 mPlayer.reset()을 호출합니다.이 문제는 보이지 않습니다. 이러한 로그 항목을 생성하는 것은 앱이라고 확신합니까?

또한 ANR이 발생할 수 있으므로 미디어 플레이어 호출이 UI 스레드에서 실행되지 않는 것이 중요합니다. MediaPlayer는 스레드로부터 안전하지 않으므로 미디어 플레이어 호출이 직렬화되도록 동일한 백그라운드 스레드에서 모두 실행하십시오.

+0

문제가 해결되면 ... 해결되었습니다. LogCat은 쓰레기를 더 이상 배출하지 않습니다. – Carnivoris