Media projections require a fore

2020-03-21  本文已影响0人  silladus
Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PRO

Android Q (Android10) 中,MediaProjection必须在前台服务中进行
参考链接:https://blog.csdn.net/qq_36332133/article/details/96485285

关键是要声明权限

  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

然后以
startForegroundService(service);的方式启动服务
同时不要忘记startForeground(id, notification);设置服务,
不然会报异常

Context.startForegroundService() did not then call Service.startForeground()
上一篇 下一篇

猜你喜欢

热点阅读