gpt4 book ai didi

android - 音频播放期间打瞌睡模式/应用程序待机

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:02:11 25 4
gpt4 key购买 nike

我注意到我的音频流应用程序在 Android 6.0 设备上存在问题。音频流是通过 HLS 通过网络连接完成的。音频播放发生在具有 Activity 通知的前台服务中。我注意到的是,当应用程序进入休眠模式/应用程序待机时,wifi 连接丢失并且播放暂停。我的服务在前台并有一个 Activity 通知,根据文档,该通知应该使我的应用程序不被中断。我还获得并维护了一个 Wifi Lock。我读过有关将我的应用程序列入白名单的信息,但是像 Spotify 这样的应用程序不会请求任何特殊权限来避免此问题。有什么想法或建议吗?

最佳答案

推荐的解决方案是采用单独的进程,一个用于音频播放,一个用于 UI。 See this long thread for lots of details

这是 Hackborn 女士的相关部分:

... have your foreground service run in a different process than the activity. From what I can see, this will work fine. I would be interesting in seeing if you get the desired behavior there.

Also this is actually our recommended practice for this situation -- if you have a long-running foreground service, it should be in a separate process from the activity, so it doesn't force all of the memory associated with the activity to be kept around. (This is also why this bug got through, all of our [Google] apps use this pattern.)

关于android - 音频播放期间打瞌睡模式/应用程序待机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35438786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com