Search code examples
androidandroid-permissionsandroid-mediaprojectionmediaprojectionmanager

Android 5.0 how to automatically obtain permissions when recording the screen?


MediaProjectionManager.createScreenCaptureIntent();

When sharing the screen, a window asking for permission will pop up.

I am looking for a way to automatically obtain all content (permissions) on the screen.

I have root access to this device!

Thanks in advance!


Solution

  • If this is for testing where you have ADB access to the device – the media projection checks the OP_PROJECT_MEDIA AppOps (code), and you can enable it through ADB like this:

    adb shell cmd appops set <your.package.name> PROJECT_MEDIA allow