Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#inhmethods)

# MediaProjectionConfig.Builder

*** ** * ** ***


`
public
static
final

class
MediaProjectionConfig.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.projection.MediaProjectionConfig.Builder |

<br />

*** ** * ** ***

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#build()() ` Builds a new immutable instance of `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig` |
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setAudioRequested(boolean)(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. |
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setInitiallySelectedSource(int)(int projectionSource) ` Indicates which projection source the UI component should display to the user first. |
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setOwnAppContentProvided(boolean)(boolean isEnabled) ` Indicates to the system that the requesting application is offering its own `https://developer.android.com/reference/android/media/projection/MediaProjectionAppContent` to be shared as `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP_CONTENT`. |
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setRequesterHint(java.lang.String)(https://developer.android.com/reference/java/lang/String requesterHint) ` Let the requesting app indicate who the requester of this `https://developer.android.com/reference/android/media/projection/MediaProjection` session is. |
| ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | ` https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setSourceEnabled(int,%20boolean)(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 |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

<br />

<br />

## Public methods

### build

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MediaProjectionConfig build ()
```

Builds a new immutable instance of `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig` | This value cannot be `null`. <br /> |

### setAudioRequested

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `isAudioRequested` | `boolean`: true to request that the UI shows an audio capture option, false otherwise. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | this Builder instance for chaining. This value cannot be `null`. <br /> |

### setInitiallySelectedSource

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `projectionSource` | `int`: Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_DISPLAY` - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP` - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP_CONTENT` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | instance of this `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder`. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#setSourceEnabled(int,%20boolean)`

### setOwnAppContentProvided

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MediaProjectionConfig.Builder setOwnAppContentProvided (boolean isEnabled)
```

Indicates to the system that the requesting application is offering its own
`https://developer.android.com/reference/android/media/projection/MediaProjectionAppContent` to be shared as
`https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP_CONTENT`.

When `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder#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
`https://developer.android.com/` inheriting from `https://developer.android.com/reference/android/media/projection/AppContentProjectionService` and
declare an intent filter with an
`https://developer.android.com/reference/android/media/projection/AppContentProjectionService#SERVICE_INTERFACE` action. The service must be
exported and protected by the `https://developer.android.com/`
permission

<br />

```
 </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
`https://developer.android.com/reference/android/media/projection/AppContentProjectionService#onContentRequest(android.media.projection.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,
`https://developer.android.com/reference/android/media/projection/AppContentProjectionService#onLoopbackProjectionStarted(android.media.projection.AppContentProjectionSession,%20int)`
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 `https://developer.android.com/reference/android/media/projection/AppContentProjectionSession#notifySessionStop()`. If the session is
stopped outside of this application
`https://developer.android.com/reference/android/media/projection/AppContentProjectionService#onSessionStopped(android.media.projection.AppContentProjectionSession)`
will be called.

<br />

| Parameters ||
|---|---|
| `isEnabled` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | This value cannot be `null`. <br /> |

### setRequesterHint

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MediaProjectionConfig.Builder setRequesterHint (String requesterHint)
```

Let the requesting app indicate who the requester of this `https://developer.android.com/reference/android/media/projection/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.

<br />

| Parameters ||
|---|---|
| `requesterHint` | `String`: the text representing the requester of this session. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | instance of this `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder`. This value cannot be `null`. <br /> |

### setSourceEnabled

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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

<br />

| Parameters ||
|---|---|
| `source` | `int`: the projection source to enable or disable. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_DISPLAY` - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP` - `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig#PROJECTION_SOURCE_APP_CONTENT` |
| `enabled` | `boolean`: true to enable the source, false otherwise <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/projection/MediaProjectionConfig.Builder` | this instance for chaining. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the source is not one of the valid sources. |