# ResolutionSelector.Builder

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/resolutionselector/ResolutionSelector.java+class:androidx.camera.core.resolutionselector.ResolutionSelector.Builder) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

*** ** * ** ***


```
public final class ResolutionSelector.Builder
```

<br />

*** ** * ** ***

Builder for a `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#Builder()()` Creates a Builder instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector` | `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#build()()` Builds the resolution selector. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder` | `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#setAllowedResolutionMode(int)(int mode)` Sets the allowed resolution mode. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder` | `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#setAspectRatioStrategy(androidx.camera.core.resolutionselector.AspectRatioStrategy)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy aspectRatioStrategy)` Sets the aspect ratio selection strategy for the `https://developer.android.com/reference/androidx/camera/core/UseCase`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder` | `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#setResolutionFilter(androidx.camera.core.resolutionselector.ResolutionFilter)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionFilter resolutionFilter)` Sets the resolution filter to output the final desired sizes list. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder` | `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector.Builder#setResolutionStrategy(androidx.camera.core.resolutionselector.ResolutionStrategy)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionStrategy resolutionStrategy)` Sets the resolution selection strategy for the `https://developer.android.com/reference/androidx/camera/core/UseCase`. |

## Public constructors

### Builder

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public Builder()
```

Creates a Builder instance.

## Public methods

### build

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull ResolutionSelector build()
```

Builds the resolution selector. This will create a resolution selector that can be used to select the desired resolution for the captured image.

### setAllowedResolutionMode

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull ResolutionSelector.Builder setAllowedResolutionMode(int mode)
```

Sets the allowed resolution mode.

If not specified, the default setting is `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector#PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION()`.

### setAspectRatioStrategy

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull ResolutionSelector.Builder setAspectRatioStrategy(@NonNull AspectRatioStrategy aspectRatioStrategy)
```

Sets the aspect ratio selection strategy for the `https://developer.android.com/reference/androidx/camera/core/UseCase`. The aspect ratio selection strategy determines how the `https://developer.android.com/reference/androidx/camera/core/UseCase` will choose the aspect ratio of the captured image.

If the aspect ratio strategy is not specified, `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy#RATIO_4_3_FALLBACK_AUTO_STRATEGY()` will be used as the default.

`https://developer.android.com/reference/androidx/camera/core/UseCase`s can be bound by a `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` with a `https://developer.android.com/reference/androidx/camera/core/ViewPort` setting. If a `https://developer.android.com/reference/androidx/camera/core/ViewPort` is set, it is recommended that the `https://developer.android.com/reference/androidx/camera/core/ViewPort` and the bound `https://developer.android.com/reference/androidx/camera/core/UseCase`s should have matching aspect ratio settings. Otherwise, the output crop rectangles may be double-cropped from the full camera sensor field of view. See `https://developer.android.com/reference/androidx/camera/core/ViewPort.Builder` for details.

CameraX only supports the common 4:3 and 16:9 aspect ratio settings. Some devices may offer additional output sizes. To access these, you'll need to create a `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector` with a `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionFilter` to find and select those specific sizes.

### setResolutionFilter

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull ResolutionSelector.Builder setResolutionFilter(@NonNull ResolutionFilter resolutionFilter)
```

Sets the resolution filter to output the final desired sizes list. The resolution filter will filter out unsuitable sizes and sort the resolution list in the preferred order. The preferred order is the order in which the resolutions should be tried first.

### setResolutionStrategy

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull ResolutionSelector.Builder setResolutionStrategy(@NonNull ResolutionStrategy resolutionStrategy)
```

Sets the resolution selection strategy for the `https://developer.android.com/reference/androidx/camera/core/UseCase`. The resolution selection strategy determines how the `https://developer.android.com/reference/androidx/camera/core/UseCase` will choose the resolution of the captured image.

Note: `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionStrategy` works in conjunction with `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy` and the default `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy` is `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy#RATIO_4_3_FALLBACK_AUTO_STRATEGY()`. Ensure you set a corresponding `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy` alongside your `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionStrategy`. For example, if your `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionStrategy` uses a bound size of `1920x1080` and a 16:9 aspect ratio is preferred, set `https://developer.android.com/reference/androidx/camera/core/resolutionselector/AspectRatioStrategy#RATIO_16_9_FALLBACK_AUTO_STRATEGY()` when building the `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector`.

CameraX only supports the common 4:3 and 16:9 aspect ratio settings. To select resolution of other aspect ratios, you'll need to create a `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector` with a `https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionFilter` to find and select those specific sizes.