android / android/media-samples
Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
Open
- Dominant language
- Kotlin
- Stars
- 1.4k
- Forks
- 781
- PR merge metrics
- No merged PRs in 30d
Description
On ScreenCapture (Android 10, SDK 29)
When fire "projectionManager.getMediaProjection()" line then it throw.
---
java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
---
How can i fix it?
Contributor guide
Research direction
Start with the ScreenCapture flow and the projectionManager.getMediaProjection() call mentioned in the report, then inspect how the sample configures its foreground service on Android 10. Done means the ScreenCapture sample no longer throws the reported SecurityException when obtaining the media projection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100