ProviderChooserIntent
public
class
ProviderChooserIntent
extends Object
java.lang.Object | |
↳ | android.support.wearable.complications.ProviderChooserIntent |
This class is deprecated.
use the Jetpack Wear
Watch Face libraries instead.
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 | |
---|---|
Constants
EXTRA_PROVIDER_INFO
public static final 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.
Constant Value: "android.support.wearable.complications.EXTRA_PROVIDER_INFO"
Public methods
createProviderChooserIntent
public 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. 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 Activity.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 WatchFaceService.Engine.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
public 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. 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 WatchFaceService.Engine.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.
|