此问题在此处已有答案:
Android - implementing startForeground for a service?(11个答案)
8个月前关闭。
我已经创建了一个简单的应用程序(以下链接How to Play Sound On Button Click in Android Studio Java 2021),一切正常,但是,我需要这个应用程序仍然可以播放的声音后,最小化然后或阻止手机(是一个白色噪声应用程序从帮助我的宝贝女儿睡眠,我需要保持播放一整夜).
是否有任何方法或设置可以使声音在最小化或阻止应用程序后不停止?
谢谢你们所有能帮助我和我的孩子的人:)
1条答案
按热度按时间fafcakar1#
如果您添加了在后台运行应用程序的功能,就可以解决您的问题。您可以查看的资源:
基本示例:
AndroidManifest.xml
:AudioPlayerService
:祝你好运!