当我退出应用程序时,声音在后台运行 [英] When I exit an application the sound runs on the background

查看:28
本文介绍了当我退出应用程序时,声音在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建"了一个应用程序,当我返回或按主页按钮退出应用程序时,我的应用程序中的音频仍在运行!我必须关闭所有正在运行的应用才能让它停止.

I "created" an application and when I go back or I press the home button to exit from the application, the audio from my application is still running! I have to close all running apps to make it stop.

如何在按下主页按钮时停止音频运行?

How can I stop the audio running when I press the home button?

推荐答案

当您单击返回时,应用程序会继续在后台运行.如果您想在退出某个活动时随时停止播放音乐,请覆盖 onStop 或 onPause 以停止您的声音.类似的东西

When you click back, the app keeps on running in the background. If you want to stop the music any time you get out of a certain activity override onStop or onPause to stop your sound. Something like that

@Override
protected void onStop(){
    super.onStop();
    //your code for stopping the sound
}

这篇关于当我退出应用程序时,声音在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆