Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android O及以上版本 Service.startForeground()导致ANR #53

Open
yujing66 opened this issue Dec 6, 2020 · 1 comment
Open

Android O及以上版本 Service.startForeground()导致ANR #53

yujing66 opened this issue Dec 6, 2020 · 1 comment

Comments

@yujing66
Copy link

yujing66 commented Dec 6, 2020

Android 8.0 有一项复杂功能;系统不允许后台应用创建后台服务。 因此,Android 8.0 引入了一种全新的方法,即 Context.startForegroundService(),以在前台启动新服务。
在系统创建服务后,应用有5秒的时间来调用该服务的 startForeground() 方法以显示新服务的用户可见通知。如果应用在此时间限制内未调用 startForeground(),则系统将停止服务并声明此应用为 ANR。

@Martin-zhq
Copy link

确实,在应用切换成后台应用后会出现这个异常,看代码老哥应该还没更新,我们处理的方式是监听应用是否切换到后台,如果正在录音,在切换到后台后就默认录音完成...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants