-1

重複の可能性:
アプリケーションを終了すると、サウンドがバックグラウンドで実行されます

ホームボタンまたは戻るボタンをクリックしても、オーディオ/サウンドはまだ実行されていますが、オーディオのソースはswf(flash)ですが、どうすれば修正できますか?

4

2 に答える 2

1

または でプレーヤーを一時停止して解放し、onPauseまたはonStopで初期化するonStart必要がありonResumeます。Android デベロッパー サイトには、これに関するトレーニングがあります。このコードをアクティビティに追加する必要があります

    @Override
public void onPause() {
    super.onPause();  // Always call the superclass method first

    // Release the mPlayer because we don't need it when paused
    // and other activities might need to use it.
// You change this part to your implement. Stop your player
        if (mPlayer != null) {
            mPlayer .release()
            mPlayer = null;
        }
//
}

で再度初期化onResume

 @Override
public void onResume() {
    super.onResume();  // Always call the superclass method first

    // Get the mPlayer instance as the activity achieves full user focus
    if (mPlayer == null) {
        initializePlayer (); // Local method to handle mPlayer init
    }
}
于 2012-09-29T14:04:26.107 に答える
1

onPause メソッドをオーバーライドし、そこでオーディオを停止する必要があります。

player.pause();
于 2012-09-29T14:00:47.217 に答える