MeasurementManager
public
class
MeasurementManager
extends Object
java.lang.Object | |
↳ | android.adservices.measurement.MeasurementManager |
MeasurementManager provides APIs to manage source and trigger registrations.
Summary
Constants | |
---|---|
int |
MEASUREMENT_API_STATE_DISABLED
This state indicates that Measurement APIs are unavailable. |
int |
MEASUREMENT_API_STATE_ENABLED
This state indicates that Measurement APIs are enabled. |
Public methods | |
---|---|
void
|
deleteRegistrations(DeletionRequest deletionRequest, Executor executor, OutcomeReceiver<Object, Exception> callback)
Delete previous registrations. |
static
MeasurementManager
|
get(Context context)
Factory method for creating an instance of MeasurementManager. |
void
|
getMeasurementApiStatus(Executor executor, OutcomeReceiver<Integer, Exception> callback)
Get Measurement API status. |
void
|
registerSource(Uri attributionSource, InputEvent inputEvent, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution source (click or view). |
void
|
registerSource(SourceRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register attribution sources(click or view) from an app context. |
void
|
registerTrigger(Uri trigger, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register a trigger (conversion). |
void
|
registerWebSource(WebSourceRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution source(click or view) from web context. |
void
|
registerWebTrigger(WebTriggerRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution trigger(click or view) from web context. |
Inherited methods | |
---|---|
Constants
MEASUREMENT_API_STATE_DISABLED
public static final int MEASUREMENT_API_STATE_DISABLED
This state indicates that Measurement APIs are unavailable. Invoking them will result in an
UnsupportedOperationException
.
Constant Value: 0 (0x00000000)
MEASUREMENT_API_STATE_ENABLED
public static final int MEASUREMENT_API_STATE_ENABLED
This state indicates that Measurement APIs are enabled.
Constant Value: 1 (0x00000001)
Public methods
deleteRegistrations
public void deleteRegistrations (DeletionRequest deletionRequest, Executor executor, OutcomeReceiver<Object, Exception> callback)
Delete previous registrations. If the deletion is successful, the callback's OutcomeReceiver.onResult(R)
is invoked with null. In case of failure, a Exception
is
sent through the callback's OutcomeReceiver#onError
. Both success and failure
feedback are executed on the provided Executor
.
Parameters | |
---|---|
deletionRequest |
DeletionRequest : The request for deleting data.
This value cannot be null . |
executor |
Executor : The executor to run callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : intended to notify asynchronously the API result.
This value cannot be null . |
get
public static MeasurementManager get (Context context)
Factory method for creating an instance of MeasurementManager.
Parameters | |
---|---|
context |
Context : The Context to use
This value cannot be null . |
Returns | |
---|---|
MeasurementManager |
A MeasurementManager instance
This value cannot be null . |
getMeasurementApiStatus
public void getMeasurementApiStatus (Executor executor, OutcomeReceiver<Integer, Exception> callback)
Get Measurement API status.
The callback's Integer
value is one of MeasurementApiState
.
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
executor |
Executor : used by callback to dispatch results.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : intended to notify asynchronously the API result.
This value cannot be null . |
registerSource
public void registerSource (Uri attributionSource, InputEvent inputEvent, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution source (click or view).
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
attributionSource |
Uri : the platform issues a request to this URI in order to fetch metadata
associated with the attribution source. The source metadata is stored on device, making
it eligible to be matched to future triggers.
This value cannot be null . |
inputEvent |
InputEvent : either an InputEvent object (for a click event) or null (for a view
event). |
executor |
Executor : used by callback to dispatch results.
This value may be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : intended to notify asynchronously the API result.
This value may be null . |
Throws | |
---|---|
IllegalArgumentException |
if the scheme for attributionSource is not HTTPS |
registerSource
public void registerSource (SourceRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register attribution sources(click or view) from an app context. This API will not process
any redirects, all registration URLs should be supplied with the request.
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
request |
SourceRegistrationRequest : app source registration request
This value cannot be null . |
executor |
Executor : used by callback to dispatch results
This value may be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : intended to notify asynchronously the API result
This value may be null . |
registerTrigger
public void registerTrigger (Uri trigger, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register a trigger (conversion).
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
trigger |
Uri : the API issues a request to this URI to fetch metadata associated with the
trigger. The trigger metadata is stored on-device, and is eligible to be matched with
sources during the attribution process.
This value cannot be null . |
executor |
Executor : used by callback to dispatch results.
This value may be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : intended to notify asynchronously the API result.
This value may be null . |
Throws | |
---|---|
IllegalArgumentException |
if the scheme for trigger is not HTTPS |
registerWebSource
public void registerWebSource (WebSourceRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution source(click or view) from web context. This API will not process any
redirects, all registration URLs should be supplied with the request. At least one of
appDestination or webDestination parameters are required to be provided. If the registration
is successful, callback
's OutcomeReceiver#onResult
is invoked with null. In
case of failure, a Exception
is sent through callback
's OutcomeReceiver.onError(E)
. Both success and failure feedback are executed on the provided
Executor
.
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
request |
WebSourceRegistrationRequest : source registration request
This value cannot be null . |
executor |
Executor : used by callback to dispatch results.
This value may be null . |
callback |
OutcomeReceiver : intended to notify asynchronously the API result.
This value may be null . |
registerWebTrigger
public void registerWebTrigger (WebTriggerRegistrationRequest request, Executor executor, OutcomeReceiver<Object, Exception> callback)
Register an attribution trigger(click or view) from web context. This API will not process
any redirects, all registration URLs should be supplied with the request. If the registration
is successful, callback
's OutcomeReceiver#onResult
is invoked with null. In
case of failure, a Exception
is sent through callback
's OutcomeReceiver.onError(E)
. Both success and failure feedback are executed on the provided
Executor
.
Requires AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION
Parameters | |
---|---|
request |
WebTriggerRegistrationRequest : trigger registration request
This value cannot be null . |
executor |
Executor : used by callback to dispatch results
This value may be null . |
callback |
OutcomeReceiver : intended to notify asynchronously the API result
This value may be null . |