Google is committed to advancing racial equity for Black communities. See how.

ProviderInfoRetriever

public class ProviderInfoRetriever
extends Object implements AutoCloseable

java.lang.Object
   ↳ androidx.wear.complications.ProviderInfoRetriever


Retrieves ComplicationProviderInfo for a watch face's complications.

To use construct an instance and call retrieveProviderInfo(ComponentName, int[]) which returns a ListenableFuture.

Further calls to retrieveProviderInfo(ComponentName, int[]) may be made using the same instance of this class, but close() must be called when it is no longer needed. Once release has been called, further retrieval attempts will fail.

Summary

Nested classes

class ProviderInfoRetriever.ProviderInfo

Results for ProviderInfoRetriever.retrieveProviderInfo(ComponentName, int[])

Public constructors

ProviderInfoRetriever(Context context)

Public methods

void close()

Releases the connection to the complication system used by this class.

ListenableFuture<ProviderInfoRetriever.ProviderInfo> retrieveProviderInfo(ComponentName watchFaceComponent, int[] watchFaceComplicationIds)

Requests ComplicationProviderInfo for the specified complication ids on the specified watch face.

Inherited methods

Public constructors

ProviderInfoRetriever

public ProviderInfoRetriever (Context context)

Parameters
context Context: the current context

Public methods

close

public void close ()

Releases the connection to the complication system used by this class. This must be called when the retriever is no longer needed.

Any outstanding or subsequent futures returned by retrieveProviderInfo(ComponentName, int[]) will resolve with null. This class implements the Java AutoClosable interface and may be used with try-with-resources.

retrieveProviderInfo

public ListenableFuture<ProviderInfoRetriever.ProviderInfo> retrieveProviderInfo (ComponentName watchFaceComponent, 
                int[] watchFaceComplicationIds)

Requests ComplicationProviderInfo for the specified complication ids on the specified watch face. When the info is received, the listener will receive a callback for each id. These callbacks will occur on the main thread.

This will only work if the package of the current app is the same as the package of the specified watch face.

Parameters
watchFaceComponent ComponentName: the ComponentName of the WatchFaceService for which info is being requested

watchFaceComplicationIds int: ids of the complications that info is being requested for

Returns
ListenableFuture<ProviderInfoRetriever.ProviderInfo> A ListenableFuture for the requested provider info. If the look up fails null will be returned