Screenshot in Android with MediaProjection
I am a newbie in android programmin and write small application with Kotlin in Android Studio 2024. I need make screenshot of another application. I see MediaProjection as good way. My app has MainActivity and service. When executing
projection = mediaProjectionManager.getMediaProjection(resultCode, data!!)
i error
“Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION”
and app crashes. I see many docs, add notifications, permissions, but no luck. Need help!