WearWidgetConfigExtras

class WearWidgetConfigExtras


Holds the configuration parameters passed to a Wear Widget configuration activity via its launching Intent.

When the Wear OS host launches a widget configuration activity (specified via configIntentAction in the <wearwidget-provider> XML metadata and matching CATEGORY_PROVIDER_CONFIG), it includes the target widget instance ID and provider service ComponentName in the launching intent's extras. Use fromIntent to extract these values in your configuration activity.

Summary

Constants

const String

Category for widget provider configuration activities.

const String

Intent extra used to supply the widget provider ComponentName (the GlanceWearWidgetService) to a widget provider configuration activity.

const String

Intent extra used to supply the widget instance ID (Int, matching WidgetInstanceId.id) to a widget provider configuration activity.

Public companion functions

WearWidgetConfigExtras?
fromIntent(intent: Intent)

Extracts WearWidgetConfigExtras from the launching configuration intent.

Public constructors

WearWidgetConfigExtras(
    instanceId: WidgetInstanceId,
    provider: ComponentName
)

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

WidgetInstanceId

The WidgetInstanceId of the widget instance being configured.

ComponentName

The ComponentName of the GlanceWearWidgetService providing the widget.

Constants

CATEGORY_PROVIDER_CONFIG

const val CATEGORY_PROVIDER_CONFIG: String

Category for widget provider configuration activities.

The configuration activity launched for configuring a widget provider must specify this category in its intent filter.

For example, in AndroidManifest.xml:

<activity
android:name=".ProviderConfigurationActivity"
android:exported="true">
<intent-filter>
<action android:name="com.example.ACTION_CONFIGURE_WIDGET" />
<category android:name="com.google.android.clockwork.tiles.category.PROVIDER_CONFIG" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

EXTRA_CONFIG_PROVIDER_COMPONENT

const val EXTRA_CONFIG_PROVIDER_COMPONENT: String

Intent extra used to supply the widget provider ComponentName (the GlanceWearWidgetService) to a widget provider configuration activity.

EXTRA_CONFIG_WIDGET_ID

const val EXTRA_CONFIG_WIDGET_ID: String

Intent extra used to supply the widget instance ID (Int, matching WidgetInstanceId.id) to a widget provider configuration activity.

Public companion functions

fromIntent

Added in 1.0.0-alpha22
fun fromIntent(intent: Intent): WearWidgetConfigExtras?

Extracts WearWidgetConfigExtras from the launching configuration intent.

Parameters
intent: Intent

The Intent that launched the widget configuration activity.

Returns
WearWidgetConfigExtras?

The parsed WearWidgetConfigExtras, or null if the intent does not have CATEGORY_PROVIDER_CONFIG or if the required extras (EXTRA_CONFIG_WIDGET_ID and EXTRA_CONFIG_PROVIDER_COMPONENT) are missing or invalid.

Public constructors

WearWidgetConfigExtras

Added in 1.0.0-alpha22
WearWidgetConfigExtras(
    instanceId: WidgetInstanceId,
    provider: ComponentName
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

instanceId

Added in 1.0.0-alpha22
val instanceId: WidgetInstanceId

The WidgetInstanceId of the widget instance being configured.

provider

Added in 1.0.0-alpha22
val provider: ComponentName

The ComponentName of the GlanceWearWidgetService providing the widget.