ContextParams.Builder


public static final class ContextParams.Builder
extends Object

java.lang.Object
   ↳ android.content.ContextParams.Builder


Builder for creating a ContextParams.

Summary

Public constructors

Builder()

Create a new builder.

Builder(ContextParams params)

Create a new builder that inherits all sub-parameters by default.

Public methods

ContextParams build()

Creates a new instance.

ContextParams.Builder setAttributionTag(String attributionTag)

Sets an attribution tag against which to track permission accesses.

ContextParams.Builder setNextAttributionSource(AttributionSource next)

Sets the attribution source for the app on whose behalf you are doing the work.

ContextParams.Builder setShouldRegisterAttributionSource(boolean shouldRegister)

Sets whether the attribution source associated with the context created from these params should be registered.

Inherited methods

Public constructors

Builder

Added in API level 31
public Builder ()

Create a new builder.

This is valuable when you are interested in having explicit control over every sub-parameter, and don't want to inherit any values from an existing Context.

Developers should strongly consider using Builder(android.content.ContextParams) instead of this constructor, since that will will automatically inherit any new sub-parameters added in future platform releases.

Builder

Added in API level 31
public Builder (ContextParams params)

Create a new builder that inherits all sub-parameters by default.

This is valuable when you are only interested in overriding specific sub-parameters, and want to preserve all other parameters. Setting a specific sub-parameter on the returned builder will override any inherited value.

Parameters
params ContextParams: This value cannot be null.

Public methods

build

Added in API level 31
public ContextParams build ()

Creates a new instance.

Returns
ContextParams The new instance. This value cannot be null.

setAttributionTag

Added in API level 31
public ContextParams.Builder setAttributionTag (String attributionTag)

Sets an attribution tag against which to track permission accesses.

Parameters
attributionTag String: The attribution tag. This value may be null.

Returns
ContextParams.Builder This builder. This value cannot be null.

setNextAttributionSource

Added in API level 31
public ContextParams.Builder setNextAttributionSource (AttributionSource next)

Sets the attribution source for the app on whose behalf you are doing the work.

Parameters
next AttributionSource: The permission identity of the receiving app. This value may be null.

Returns
ContextParams.Builder This builder. This value cannot be null.

See also:

setShouldRegisterAttributionSource

Added in API level 35
public ContextParams.Builder setShouldRegisterAttributionSource (boolean shouldRegister)

Sets whether the attribution source associated with the context created from these params should be registered.

Parameters
shouldRegister boolean: Whether the attribution source associated with the Context being created should be registered.

Returns
ContextParams.Builder This value cannot be null.