Skip to content

Most visited

Recently visited

navigation

ProviderChooserIntent

public class ProviderChooserIntent
extends Object

java.lang.Object
   ↳ android.support.wearable.complications.ProviderChooserIntent


Utilities to allow watch faces to launch the complication provider chooser.

Summary

Constants

String EXTRA_PROVIDER_INFO

Key for an extra used to include details of the chosen provider in the activity result returned by the provider chooser.

Public methods

static Intent createProviderChooserIntent(ComponentName watchFace, int watchFaceComplicationId, int... supportedTypes)

Returns an intent that may be used to start an activity to allow the user to select a provider for the given complication.

static void startProviderChooserActivity(Context context, ComponentName watchFace, int watchFaceComplicationId, int... supportedTypes)

Starts an activity to allow the user to select a provider for the given complication.

Inherited methods

From class java.lang.Object

Constants

EXTRA_PROVIDER_INFO

String EXTRA_PROVIDER_INFO

Key for an extra used to include details of the chosen provider in the activity result returned by the provider chooser.

See also:

Constant Value: "android.support.wearable.complications.EXTRA_PROVIDER_INFO"

Public methods

createProviderChooserIntent

Intent createProviderChooserIntent (ComponentName watchFace, 
                int watchFaceComplicationId, 
                int... supportedTypes)

Returns an intent that may be used to start an activity to allow the user to select a provider for the given complication. The activity will show a list of all providers that can supply data of at least one of the supportedTypes.

This should only be used if the user has already granted the com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA permission. In most cases it will be easier to use ComplicationHelperActivity to perform the permission request automatically if it is not already granted.

When the user chooses a provider, the configuration will be set up in the complications system - the watch face does not need to do anything else.

The activity must be started using startActivityForResult(Intent, int), or else this will not work. The result delivered back to your activity will have a result code of RESULT_OK if a provider was successfully set, or a result code of RESULT_CANCELED if no provider was set. In the case where a provider was set, ComplicationProviderInfo for the chosen provider will be included in the data intent of the result, as an extra with the key EXTRA_PROVIDER_INFO.

The package of the calling Activity must match the package of the watch face, or this will not work.

Parameters
watchFace ComponentName: the ComponentName of the WatchFaceService being configured.

watchFaceComplicationId int: the watch face's id for the complication being configured. This must match the id passed in when the watch face calls setActiveComplications(int...).

supportedTypes int: the types supported by the complication, in decreasing order of preference. If a provider can supply data for more than one of these types, the type chosen will be whichever was specified first.

Returns
Intent

See also:

startProviderChooserActivity

void startProviderChooserActivity (Context context, 
                ComponentName watchFace, 
                int watchFaceComplicationId, 
                int... supportedTypes)

Starts an activity to allow the user to select a provider for the given complication. The activity will show a list of all providers that can supply data of at least one of the supportedTypes.

This should only be used if the user has already granted the com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA permission. In most cases it will be easier to use ComplicationHelperActivity to perform the permission request automatically if it is not already granted.

This is intended for use when starting the chooser directly from the watch face. If the chooser is being started from an Activity, use createProviderChooserIntent(ComponentName, int, int...) instead.

The package of the caller must match the package of the watch face, or this will not work.

Parameters
context Context: used to start the activity.

watchFace ComponentName: the ComponentName of the WatchFaceService being configured.

watchFaceComplicationId int: the watch face's id for the complication being configured. This must match the id passed in when the watch face calls setActiveComplications(int...).

supportedTypes int: the types supported by the complication, in decreasing order of preference. If a provider can supply data for more than one of these types, the type chosen will be whichever was specified first.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)