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

233 Views Asked by At

I have an app which has the feature of casting the screen using the Media Projection API in android

With the recently released beta (3.1) for Android 14 the user has to select the option to cast a single app or the full screen.

Single App

With this option the user is able to select the app which they want to share the screen with others. This option allows the media projection to be stopped when the app is killed

Entire screen

This casts the entire phone's screen without any restriction


Is there any way to set the option to the entire screen by default?

So far i have tried to find which option the user selected by using the Media Projection manager in my code, but still can't find any solutions so I'm stuck on this

so please share your answers it will be helpfull for all . thanks in advance

Note : This feature is released in Android 14 Beta 3.1 program. so far the listed device from google can get this feature update if they join the beta

enter image description here

1

There are 1 best solutions below

1
Caio Arthur On BEST ANSWER

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.