public final class QualitySelector

QualitySelector defines a desired quality setting that can be used to configure components with quality setting requirements such as creating a Recorder.

There are pre-defined quality constants that are universally used for video, such as SD, HD, FHD and UHD, but not all of them are supported on every device since each device has its own capabilities. isQualitySupported can be used to check whether a quality is supported on the device or not and getResolution can be used to get the actual resolution defined in the device. Aside from checking the qualities one by one, QualitySelector provides a more convenient way to select a quality. The typical usage of selecting a single desired quality is:

  QualitySelector qualitySelector = QualitySelector.from(Quality.FHD);

or the usage of selecting a series of qualities by desired order:

  QualitySelector qualitySelector = QualitySelector.fromOrderedList(
          Arrays.asList(Quality.FHD, Quality.HD, Quality.HIGHEST)
  );

The recommended way is giving a guaranteed supported quality such as LOWEST or HIGHEST in the end of the desired quality list, which ensures the QualitySelector can always choose a supported quality. Another way to ensure a quality will be selected when none of the desired qualities are supported is to use fromOrderedList with an open-ended fallback strategy such as a fallback strategy from lowerQualityOrHigherThan:

  QualitySelector qualitySelector = QualitySelector.fromOrderedList(
          Arrays.asList(Quality.UHD, Quality.FHD),
          FallbackStrategy.lowerQualityOrHigherThan(Quality.FHD)
  );

If UHD and FHD are not supported on the device, QualitySelector will select the quality that is closest to and lower than FHD. If no lower quality is supported, the quality that is closest to and higher than FHD will be selected.

Summary

Public methods

getSupportedQualities

public static @NonNull List<QualitygetSupportedQualities(@NonNull CameraInfo cameraInfo)

Gets all supported qualities on the device.

The returned list is sorted by quality size from largest to smallest. For the qualities in the returned list, with the same input cameraInfo, isQualitySupported will return true and getResolution will return the corresponding resolution.

Note: Constants HIGHEST and LOWEST are not included in the returned list, but their corresponding qualities are included.

isQualitySupported

public static boolean isQualitySupported(
    @NonNull CameraInfo cameraInfo,
    @NonNull Quality quality
)

Checks if the quality is supported.

Calling this method with one of the qualities contained in the returned list of getSupportedQualities will return true.

Possible values for quality include LOWEST, HIGHEST, SD, HD, FHD and UHD.

If this method is called with LOWEST or HIGHEST, it will return true except the case that none of the qualities can be supported.

Returns
boolean

true if the quality is supported; false otherwise.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-05-15 UTC.