该应用程序的声音媒体在后台运行如何解决它? [英] The app sounds media run in the background how to fix it?
本文介绍了该应用程序的声音媒体在后台运行如何解决它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/12652133/when-i-exit-an-application-the-sound-runs-on-the-background\">When我退出的声音在背景运行的应用程序
当我点击主页按钮或后退按钮,音频/声音仍在运行,音频的来源是SWF(闪存),所以我该如何解决?
When i click the home button or back button, the audio/sound still running, the source of the audio is swf(flash) so how can i fix it?
推荐答案
您应暂停,并在的onPause
或的onStop $ c释放播放器$ C>和init在
在onStart
或 onResume
。 Android开发者网站上有的培训了解这个。你应该在你的活动添加此code
You should pause and release player in onPause
or onStop
and init in onStart
or onResume
. Android Developer site has training about this. You should add this code in your activity
@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
}
}
这篇关于该应用程序的声音媒体在后台运行如何解决它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文