android / android/media-samples

Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION

Open
#65 0 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.