MediaProjectionConfig.Builder
public
static
final
class
MediaProjectionConfig.Builder
extends Object
| java.lang.Object | |
| ↳ | android.media.projection.MediaProjectionConfig.Builder |
Summary
Public constructors | |
|---|---|
Builder()
|
|
Public methods | |
|---|---|
MediaProjectionConfig
|
build()
Builds a new immutable instance of |
MediaProjectionConfig.Builder
|
setAudioRequested(boolean isAudioRequested)
This method informs the screen capture UI that the user should be presented with an option to also record audio along with the screen content. |
MediaProjectionConfig.Builder
|
setInitiallySelectedSource(int projectionSource)
Indicates which projection source the UI component should display to the user first. |
MediaProjectionConfig.Builder
|
setOwnAppContentProvided(boolean isEnabled)
Indicates to the system that the requesting application is offering its own
|
MediaProjectionConfig.Builder
|
setRequesterHint(String requesterHint)
Let the requesting app indicate who the requester of this |
MediaProjectionConfig.Builder
|
setSourceEnabled(int source, boolean enabled)
Set whether the UI component requesting the user permission to share their screen should display an option to share the specified source |
Inherited methods | |
|---|---|
Public constructors
Public methods
build
public MediaProjectionConfig build ()
Builds a new immutable instance of MediaProjectionConfig
| Returns | |
|---|---|
MediaProjectionConfig |
This value cannot be null. |
setAudioRequested
public MediaProjectionConfig.Builder setAudioRequested (boolean isAudioRequested)
This method informs the screen capture UI that the user should be presented with an
option to also record audio along with the screen content. When isAudioRequested is set to true, the consent dialog will display a control, such as a
toggle, allowing the user to enable or disable audio capture for the projection
session. If set to false, this control will not be shown.
| Parameters | |
|---|---|
isAudioRequested |
boolean: true to request that the UI shows an audio capture
option, false otherwise. |
| Returns | |
|---|---|
MediaProjectionConfig.Builder |
this Builder instance for chaining.
This value cannot be null. |
setInitiallySelectedSource
public MediaProjectionConfig.Builder setInitiallySelectedSource (int projectionSource)
Indicates which projection source the UI component should display to the user first. Calling this method without enabling the respective choice will have no effect.
| Parameters | |
|---|---|
projectionSource |
int: Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
MediaProjectionConfig.Builder |
instance of this Builder.
This value cannot be null. |
See also:
setOwnAppContentProvided
public MediaProjectionConfig.Builder setOwnAppContentProvided (boolean isEnabled)
Indicates to the system that the requesting application is offering its own
content to be shared as
MediaProjectionConfig.PROJECTION_SOURCE_APP_CONTENT.
When setOwnAppContentProvided(boolean) is set to true, the requesting
app's content will override any content from other apps that might have been displayed
by the system.
If this application wishes to offer its own content to be shared, it must declare, in
its manifest, a
ERROR(/android.os.Service) inheriting from AppContentProjectionService and
declare an intent filter with an
AppContentProjectionService.SERVICE_INTERFACE action. The service must be
exported and protected by the ERROR(/android.Manifest.permission#MANAGE_MEDIA_PROJECTION)
permission
</application>
...
<service
android:exported="true"
android:name="com.example.AppContentSharingService"
android:permission="android.permission.MANAGE_MEDIA_PROJECTION">
<intent-filter>
<action android:name="android.media.projection.AppContentProjectionService"/>
</intent-filter>
</service>
</application>
If supported by the device, the content will be displayed to the user in the media
projection picker and
AppContentProjectionService.onContentRequest(AppContentRequest)
will be called, offering the a chance to this application to provide or update the
content to be shared.
If the user selects an item from this list,
AppContentProjectionService.onLoopbackProjectionStarted(AppContentProjectionSession,int)
will be called and the projection session will be considered as started.
If the shared content becomes unavailable, this application will be responsible for
calling AppContentProjectionSession.notifySessionStop(). If the session is
stopped outside of this application
AppContentProjectionService.onSessionStopped(AppContentProjectionSession)
will be called.
| Parameters | |
|---|---|
isEnabled |
boolean |
| Returns | |
|---|---|
MediaProjectionConfig.Builder |
This value cannot be null. |
setRequesterHint
public MediaProjectionConfig.Builder setRequesterHint (String requesterHint)
Let the requesting app indicate who the requester of this MediaProjection
session is.
The UI component prompting the user for the permission to start the session can use this hint to provide more information about the origin of the request (e.g. a browser tab title, a meeting id if sharing to a video conferencing app, a player name if sharing the screen within a game).
Note that setting this won't hide or change the name of the application requesting the session.
| Parameters | |
|---|---|
requesterHint |
String: the text representing the requester of this session.
This value may be null. |
| Returns | |
|---|---|
MediaProjectionConfig.Builder |
instance of this Builder.
This value cannot be null. |
setSourceEnabled
public MediaProjectionConfig.Builder setSourceEnabled (int source, boolean enabled)
Set whether the UI component requesting the user permission to share their screen should display an option to share the specified source
| Parameters | |
|---|---|
source |
int: the projection source to enable or disable.
Value is either 0 or a combination of the following:
|
enabled |
boolean: true to enable the source, false otherwise |
| Returns | |
|---|---|
MediaProjectionConfig.Builder |
this instance for chaining.
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if the source is not one of the valid sources. |