# WearWidgetProviderInfo

Artifact: [androidx.glance.wear:wear-core](https://developer.android.com/jetpack/androidx/releases/glance-wear) [View Source](https://cs.android.com/search?q=file:androidx/glance/wear/core/WearWidgetProviderInfo.kt+class:androidx.glance.wear.core.WearWidgetProviderInfo) Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)


```
class WearWidgetProviderInfo
```

<br />

*** ** * ** ***

Describes the metadata for a Wear Widget provider.

The fields in this class correspond to the fields in the `<wearwidget-provider>` xml tag.

For example, the `AndroidManifest.xml` would contain:

```kotlin
<service
    android:name=".MyWidgetService"
    android:exported="true">
    <meta-data
        android:name="androidx.glance.wear.widget.provider"
        android:resource="@xml/my_widget_info" />
</service>
```

And `res/xml/my_widget_info.xml` would contain:

```kotlin
<wearwidget-provider
    label="@string/widget_label"
    description="@string/widget_description"
    icon="@drawable/widget_icon"
    preferredType="@integer/glance_wear_container_type_small" >

    <container
        type="@integer/glance_wear_container_type_small"
        previewImage="@drawable/small_preview"/>

    <container
        type="@integer/glance_wear_container_type_large"
        previewImage="@drawable/large_preview"
        label="@string/large_container_label_override" />

</wearwidget-provider>
```

For container types, see `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo.ContainerType`. In XML metadata for your widgets, these should be referenced by using the public integer resources `@integer/glance_wear_container_type_large` and `@integer/glance_wear_container_type_small`. These correspond to the integer constants `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo#CONTAINER_TYPE_LARGE()` and `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo#CONTAINER_TYPE_SMALL()`.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#parseFromService(android.content.Context,android.content.ComponentName)(context: https://developer.android.com/reference/android/content/Context.html, providerService: https://developer.android.com/reference/android/content/ComponentName.html)` Parses a `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo` from the metadata of a service. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#configIntentAction()` The intent action to launch an activity for configuring the widget. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo>` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#containers()` The list of `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo` supported for this widget provider. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#description()` The description of this widget. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#group()` The name of the group this widget provider is associated with. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#icon()` The resource id of the icon for this widget. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#label()` The label of this widget. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#preferredContainerType()` The preferred Container Type to use for a widget instance when type is not specified when adding a widget. |
| `https://developer.android.com/reference/android/content/ComponentName.html` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#providerService()` The `https://developer.android.com/reference/android/content/ComponentName.html` of this widget provider. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo#unrecognisedAttributes()` Any unrecognised attributes during the XML parsing of the provider info. |

## Public companion functions

### parseFromService

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
fun parseFromService(context: Context, providerService: ComponentName): WearWidgetProviderInfo
```

Parses a `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetProviderInfo` from the metadata of a service.

The metadata with name `androidx.glance.wear.widget.provider` should reference an XML resource with the provider info.

If not present, the values for label, description and icon are taken from the attributes.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The `https://developer.android.com/reference/android/content/Context.html` to use for resolving resources and package manager. |
| `providerService: https://developer.android.com/reference/android/content/ComponentName.html` | The `https://developer.android.com/reference/android/content/ComponentName.html` of the widget provider service. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/content/pm/PackageManager.NameNotFoundException.html` | if the meta-data resource is not found or the provider service is not found. |
| `https://developer.android.com/reference/org/xmlpull/v1/XmlPullParserException.html` | if there is an error parsing the XML resource or if this is not a valid provider info, for example: - No `<container>` tags are defined. - Multiple `<container>` tags have the same `type`. - Invalid resource IDs. - Using `CONTAINER_TYPE_TILE_COMPAT` which is not supported for widgets. |

## Public properties

### configIntentAction

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val configIntentAction: String?
```

The intent action to launch an activity for configuring the widget. This can be null if no configuration is needed.

### containers

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val containers: List<ContainerInfo>
```

The list of `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo` supported for this widget provider. Each element represents a supported type.

### description

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val description: String
```

The description of this widget.

### group

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val group: String
```

The name of the group this widget provider is associated with. Widget providers in the same group represent the same widget on the device. Only one provider service should be enabled at a time for a given group. This can be used to replace which provider service is associated with a widget on the device.

Defaults to the fully qualified name of the provider service.

This attribute is only used on devices on API version 37 and above. For backwards compatibility with services being used on older devices, the default value of the fully qualified name of the older service should be used.

### icon

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val icon: @DrawableRes Int
```

The resource id of the icon for this widget.

### label

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val label: String
```

The label of this widget.

### preferredContainerType

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val preferredContainerType: Int
```

The preferred Container Type to use for a widget instance when type is not specified when adding a widget. This can be used when this provider is replacing a legacy Wear Tile provider. See `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/ContainerInfo`.

Value is one of the following:

- `0`
- `1`
- `2`

<br />

### providerService

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val providerService: ComponentName
```

The `https://developer.android.com/reference/android/content/ComponentName.html` of this widget provider.

### unrecognisedAttributes

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
val unrecognisedAttributes: Map<String, String>
```

Any unrecognised attributes during the XML parsing of the provider info.