[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/android/adservices/common/KeyedFrequencyCap.Builder [Back]  [Original]

KeyedFrequencyCap.Builder  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.

KeyedFrequencyCap.Builder


public static final class KeyedFrequencyCap.Builder
extends Object

java.lang.Object
   ↳ android.adservices.common.KeyedFrequencyCap.Builder


This class was deprecated in API level 37.
The Rubidium (Rb) Relevance APIs, including those in android.adservices.common, are being deprecated. Relevance APIs have no direct replacement. Developers should stop using them, as calls will be rejected in future Android releases. Please refer to official Privacy Sandbox documentation for deprecation and roadmap details: https://privacysandbox.com/news/update-on-plans-for-privacy-sandbox-technologies/

Builder for creating KeyedFrequencyCap objects.

Summary

Public constructors

Builder(int adCounterKey, int maxCount, Duration interval)

Public methods

KeyedFrequencyCap build()

Builds and returns a KeyedFrequencyCap instance.

KeyedFrequencyCap.Builder setAdCounterKey(int adCounterKey)

Sets the ad counter key the frequency cap applies to.

KeyedFrequencyCap.Builder setInterval(Duration interval)

Sets the interval, as a Duration which will be truncated to the nearest second, over which the frequency cap is calculated.

KeyedFrequencyCap.Builder setMaxCount(int maxCount)

Sets the maximum count within the time interval for the frequency cap.

Inherited methods

Public constructors

Builder

public Builder (int adCounterKey, 
                int maxCount, 
                Duration interval)

Parameters
adCounterKey int

maxCount int

interval Duration: This value cannot be null.

Public methods

build

Added in API level 35
Also in Ad Services Extensions 8
Deprecated in API level 37
public KeyedFrequencyCap build ()

Builds and returns a KeyedFrequencyCap instance.

Returns
KeyedFrequencyCap This value cannot be null.

setAdCounterKey

Added in API level 35
Also in Ad Services Extensions 8
Deprecated in API level 37
public KeyedFrequencyCap.Builder setAdCounterKey (int adCounterKey)

Sets the ad counter key the frequency cap applies to.

See KeyedFrequencyCap.getAdCounterKey() for more information.

Parameters
adCounterKey int

Returns
KeyedFrequencyCap.Builder This value cannot be null.

setInterval

Added in API level 35
Also in Ad Services Extensions 8
Deprecated in API level 37
public KeyedFrequencyCap.Builder setInterval (Duration interval)

Sets the interval, as a Duration which will be truncated to the nearest second, over which the frequency cap is calculated.

See KeyedFrequencyCap.getInterval() for more information.

Parameters
interval Duration: This value cannot be null.

Returns
KeyedFrequencyCap.Builder This value cannot be null.

setMaxCount

Added in API level 35
Also in Ad Services Extensions 8
Deprecated in API level 37
public KeyedFrequencyCap.Builder setMaxCount (int maxCount)

Sets the maximum count within the time interval for the frequency cap.

See KeyedFrequencyCap.getMaxCount() for more information.

Parameters
maxCount int

Returns
KeyedFrequencyCap.Builder This value cannot be null.

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 2026-08-03 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 2026-08-03 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page