Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder for creating a ContextParams
.
Summary
Public constructors |
Create a new builder.
|
Create a new builder that inherits all sub-parameters by default.
|
Public constructors
Builder
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
Builder(params: ContextParams)
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.
Public methods
setAttributionTag
fun setAttributionTag(attributionTag: String?): ContextParams.Builder
Sets an attribution tag against which to track permission accesses.
Parameters |
attributionTag |
String?: The attribution tag. This value may be null . |
setNextAttributionSource
fun setNextAttributionSource(next: AttributionSource?): ContextParams.Builder
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 . |
setShouldRegisterAttributionSource
fun setShouldRegisterAttributionSource(shouldRegister: Boolean): ContextParams.Builder
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. |
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-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ContextParams.Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/content/ContextParams.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|--------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.content.ContextParams.Builder](#) |\n\nBuilder for creating a [ContextParams](/reference/kotlin/android/content/ContextParams).\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder())`()` Create a new builder. |\n| [Builder](#Builder(android.content.ContextParams))`(`params:` `[ContextParams](/reference/kotlin/android/content/ContextParams)`)` Create a new builder that inherits all sub-parameters by default. |\n\n| Public methods ||\n|------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [ContextParams](/reference/kotlin/android/content/ContextParams) | [build](#build())`()` Creates a new instance. |\n| [ContextParams.Builder](#) | [setAttributionTag](#setAttributionTag(kotlin.String))`(`attributionTag:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets an attribution tag against which to track permission accesses. |\n| [ContextParams.Builder](#) | [setNextAttributionSource](#setNextAttributionSource(android.content.AttributionSource))`(`next:` `[AttributionSource](/reference/kotlin/android/content/AttributionSource)?`)` Sets the attribution source for the app on whose behalf you are doing the work. |\n| [ContextParams.Builder](#) | [setShouldRegisterAttributionSource](#setShouldRegisterAttributionSource(kotlin.Boolean))`(`shouldRegister:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether the attribution source associated with the context created from these params should be registered. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder()\n```\n\nCreate a new builder.\n\nThis 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.\n\nDevelopers should strongly consider using [Builder(android.content.ContextParams)](#Builder(android.content.ContextParams)) instead of this constructor, since that will will automatically inherit any new sub-parameters added in future platform releases. \n\n### Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder(params: ContextParams)\n```\n\nCreate a new builder that inherits all sub-parameters by default.\n\nThis 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.\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------|\n| `params` | [ContextParams](/reference/kotlin/android/content/ContextParams): This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): ContextParams\n```\n\nCreates a new instance.\n\n| Return ||\n|------------------------------------------------------------------|------------------------------------------------|\n| [ContextParams](/reference/kotlin/android/content/ContextParams) | The new instance. This value cannot be `null`. |\n\n### setAttributionTag\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setAttributionTag(attributionTag: String?): ContextParams.Builder\n```\n\nSets an attribution tag against which to track permission accesses.\n\n| Parameters ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `attributionTag` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: The attribution tag. This value may be `null`. |\n\n| Return ||\n|----------------------------|--------------------------------------------|\n| [ContextParams.Builder](#) | This builder. This value cannot be `null`. |\n\n### setNextAttributionSource\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setNextAttributionSource(next: AttributionSource?): ContextParams.Builder\n```\n\nSets the attribution source for the app on whose behalf you are doing the work.\n\n| Parameters ||\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `next` | [AttributionSource](/reference/kotlin/android/content/AttributionSource)?: The permission identity of the receiving app. This value may be `null`. |\n\n| Return ||\n|----------------------------|--------------------------------------------|\n| [ContextParams.Builder](#) | This builder. This value cannot be `null`. |\n\n**See Also**\n\n- [android.content.AttributionSource](/reference/kotlin/android/content/AttributionSource) \n\n### setShouldRegisterAttributionSource\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setShouldRegisterAttributionSource(shouldRegister: Boolean): ContextParams.Builder\n```\n\nSets whether the attribution source associated with the context created from these params should be registered.\n\n| Parameters ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `shouldRegister` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether the attribution source associated with the Context being created should be registered. |\n\n| Return ||\n|----------------------------|------------------------------|\n| [ContextParams.Builder](#) | This value cannot be `null`. |"]]