android / media-samples

Multiple samples showing the best practices in media APIs on Android (audio, video, etc.).
Apache License 2.0
1.27k stars 741 forks source link

The ScreenCapture example doesn't work on API 30+ #86

Open raul-guerrero opened 2 years ago

raul-guerrero commented 2 years ago

As stated in the title, the ScreenCapture example doesn't work anymore as API 30+ forcefully requires to run any MediaProjection code as a Foreground service, and even as I rewrote the sample code to run that way, it captures a black screen. I found a ticket in Google's issue tracker stating that bug, so it seems is reported, but still hasn't been addressed https://issuetracker.google.com/issues/214397245?pli=1

This is a huge problem, as most of our application's functionality relies on such feature to work, and if even the Android provided examples fail, we can't upgrade our app to the latest Android API version.

fan123199 commented 1 year ago

Yes, I got this error too "Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION". Please help to provide a runnable example.