public final class ComplicationRequest


Data associated with complication request in ComplicationDataSourceService.onComplicationRequest.

Summary

Public constructors

ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType
)

This method is deprecated. Use a constructor that specifies responseNeededSoon.

ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType,
    boolean immediateResponseRequired
)

Constructs a ComplicationRequest without setting isForSafeWatchFace.

@RequiresApi(value = 33)
ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType,
    boolean immediateResponseRequired,
    int isForSafeWatchFace
)

Public methods

final int

The system's id for the requested complication which is a unique value for the tuple Watch face ComponentName, complication slot ID.

final @NonNull ComplicationType

The ComplicationType of complication data requested.

final int

Intended for OEM use, returns whether this request is on behalf of a 'safe' watch face as defined by the ComplicationDataSourceService.METADATA_KEY_SAFE_WATCH_FACES meta data in the data source's manifest.

final boolean

If true then ComplicationRequestListener.onComplicationData should be called as soon as possible (ideally less than 100ms instead of the usual 20s deadline).

Public constructors

ComplicationRequest

Added in 1.0.0
Deprecated in 1.1.0
public ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType
)

ComplicationRequest

Added in 1.1.0
public ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType,
    boolean immediateResponseRequired
)

Constructs a ComplicationRequest without setting isForSafeWatchFace.

ComplicationRequest

Added in 1.2.0
@RequiresApi(value = 33)
public ComplicationRequest(
    int complicationInstanceId,
    @NonNull ComplicationType complicationType,
    boolean immediateResponseRequired,
    int isForSafeWatchFace
)
Parameters
int complicationInstanceId

The system's id for the requested complication which is a unique value for the tuple Watch face ComponentName, complication slot ID.

@NonNull ComplicationType complicationType

The type of complication data requested.

boolean immediateResponseRequired

If true then ComplicationRequestListener.onComplicationData should be called as soon as possible (ideally less than 100ms instead of the usual 20s deadline). This will only be true within a ComplicationDataSourceService.onStartImmediateComplicationRequests pair.

int isForSafeWatchFace

Whether this request is on behalf of a 'safe' watch face as defined by the ComplicationDataSourceService.METADATA_KEY_SAFE_WATCH_FACES meta data in the data source's manifest. The data source may choose to serve different results for a 'safe' watch face. If the data source does not have the privileged permission com.google.wear.permission.GET_IS_FOR_SAFE_WATCH_FACE, then this must be null.

Public methods

getComplicationInstanceId

Added in 1.0.0
public final int getComplicationInstanceId()

The system's id for the requested complication which is a unique value for the tuple Watch face ComponentName, complication slot ID.

getComplicationType

Added in 1.0.0
public final @NonNull ComplicationType getComplicationType()

The ComplicationType of complication data requested.

isForSafeWatchFace

Added in 1.2.0
public final int isForSafeWatchFace()

Intended for OEM use, returns whether this request is on behalf of a 'safe' watch face as defined by the ComplicationDataSourceService.METADATA_KEY_SAFE_WATCH_FACES meta data in the data source's manifest. The data source may choose to serve different results for a 'safe' watch face.

If the ComplicationDataSourceService.METADATA_KEY_SAFE_WATCH_FACES meta data is not defined then this will be TargetWatchFaceSafety.UNKNOWN.

Note if the ComplicationDataSourceService does not have the privileged permission com.google.wear.permission.GET_IS_FOR_SAFE_WATCH_FACE, then this will be TargetWatchFaceSafety.UNKNOWN.

isImmediateResponseRequired

Added in 1.1.0
public final boolean isImmediateResponseRequired()

If true then ComplicationRequestListener.onComplicationData should be called as soon as possible (ideally less than 100ms instead of the usual 20s deadline). This will only be true within a ComplicationDataSourceService.onStartImmediateComplicationRequests pair which will not be called unless the ComplicationDataSourceService has privileged permission com.google.android.wearable.permission.USE_IMMEDIATE_COMPLICATION_UPDATE.