Search code examples
mobile-developmentandroid-mediaprojection

Is there any way to set the Media Projection Permission to Entire screen option by Default in Android 14 (Beta 3.1)?


Currently, in Android 14 Beta 3.1, there isn't a built-in option to set the Media Projection Permission to Entire screen by default. Users must manually choose between casting a single app or the entire screen when granting permission to the Media Projection AP

Your attempts to determine the user's selection using the Media Projection manager in your code are reasonable. However, as of now, there doesn't appear to be a direct solution available for setting the default option to Entire screen


Solution

  • Is your app compileSdk version 34? If it is, you can use MediaProjectionConfig when calling createScreenCaptureIntent from media projection manager object.

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            screenRecorderServiceLauncher.launch(
                mediaProjectionManager.createScreenCaptureIntent(MediaProjectionConfig.createConfigForDefaultDisplay())
            )
        } else {
            screenRecorderServiceLauncher.launch(
                mediaProjectionManager.createScreenCaptureIntent()
            )
        }
    

    The createConfigForDefaultDisplay() defines the screen recorder to only allow user to use as "entire screen" when using a media projection service from your application.