public final class

RetryPolicy.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.camera.core.RetryPolicy.Builder

Overview

A builder class for customizing RetryPolicy behavior.

Use the RetryPolicy.Builder.Builder(RetryPolicy) to modify existing RetryPolicy instances, typically starting with the predefined options like RetryPolicy.DEFAULT or RetryPolicy.RETRY_UNAVAILABLE_CAMERA. The most common use is to set a custom timeout.

Example: Create a policy based on RetryPolicy.DEFAULT with a 10-second timeout:

 new RetryPolicy.Builder(RetryPolicy.DEFAULT).setTimeoutInMillis(10000L).build()
 

Summary

Constructors
publicBuilder(RetryPolicy basePolicy)

Creates a builder based on an existing RetryPolicy.

Methods
public RetryPolicybuild()

Creates the customized RetryPolicy instance.

public RetryPolicy.BuildersetTimeoutInMillis(long timeoutInMillis)

Sets a timeout in milliseconds.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(RetryPolicy basePolicy)

Creates a builder based on an existing RetryPolicy.

This allows you to start with a predefined policy and add further customizations. For example, set a timeout to prevent retries from continuing endlessly.

Parameters:

basePolicy: The RetryPolicy to use as a starting point.

Methods

public RetryPolicy.Builder setTimeoutInMillis(long timeoutInMillis)

Sets a timeout in milliseconds. If retries exceed this duration, they will be terminated with RetryPolicy.RetryConfig.NOT_RETRY.

Parameters:

timeoutInMillis: The maximum duration for retries in milliseconds. A value of 0 indicates no timeout.

Returns:

this for method chaining.

public RetryPolicy build()

Creates the customized RetryPolicy instance.

Returns:

The new RetryPolicy.