# WatchFaceConfigIntentHelper

# WatchFaceConfigIntentHelper

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper "View this page in Java")

<br />

```
class WatchFaceConfigIntentHelper
```

<br />

*** ** * ** ***

Helper functions for use by watch face configuration activities. In general, there are two distinct users:

- ones creating Intents

- ones receiving and responding to those Intents.

To register a configuration activity for a watch face, add a`<meta-data>`entry to the watch face component in its Android Manifest file with an intent action to be fired to start the activity. The following meta-data will register the`androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR`action to be started when configuring a watch face on the wearable device:  

```kotlin
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR" />
```

To register a configuration activity to be started on a companion phone, add the following alternative meta-data entry to the watch face component:  

```kotlin
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR" />
```

The activity should have an intent filter which lists the action specified in the meta-data block above, in addition to the two categories present in the following example:  

```kotlin
<activity android:name=".MyWatchFaceConfigActivity">
<intent-filter>
<action android:name="androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR" />
<category android:name=
"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
```

For phone side configuration activities, substitute the category`com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION`for`com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION`.

## Summary

|                                 ### Public companion functions                                 |
|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`           | [getPeerIdExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#getPeerIdExtra(android.content.Intent))`(watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`)` This method is for retrieving the ID of the currently connected device from the given[Intent](https://developer.android.com/reference/android/content/Intent.html).                                                                                                                                                                                                                                                        |
| [ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`?` | [getWatchFaceComponentExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#getWatchFaceComponentExtra(android.content.Intent))`(watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`)` This method is for retrieving the extended data of watch face[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)from the given[Intent](https://developer.android.com/reference/android/content/Intent.html).                                                                                                                                               |
| [Intent](https://developer.android.com/reference/android/content/Intent.html)                  | [putPeerIdExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#putPeerIdExtra(android.content.Intent,kotlin.String))`(watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`, peerId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` This method is adding the ID of the currently connected device to the given[Intent](https://developer.android.com/reference/android/content/Intent.html).                                                                                                                                                       |
| [Intent](https://developer.android.com/reference/android/content/Intent.html)                  | [putWatchFaceComponentExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#putWatchFaceComponentExtra(android.content.Intent,android.content.ComponentName))`(` ` watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`,` ` componentName: `[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html) `)` This method is for adding the extended data of watch face[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)to the given[Intent](https://developer.android.com/reference/android/content/Intent.html). |

## Public companion functions

### getPeerIdExtra

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

```
fun getPeerIdExtra(watchFaceIntent: Intent): String?
```

This method is for retrieving the ID of the currently connected device from the given[Intent](https://developer.android.com/reference/android/content/Intent.html).  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|--------------------------------------------|
| `watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html) | The intent holding config activity launch. |

|                                       Returns                                        |
|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | the value of an item previously added with[putPeerIdExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#putPeerIdExtra(android.content.Intent,kotlin.String)), or null if no value was found. |

### getWatchFaceComponentExtra

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

```
fun getWatchFaceComponentExtra(watchFaceIntent: Intent): ComponentName?
```

This method is for retrieving the extended data of watch face[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)from the given[Intent](https://developer.android.com/reference/android/content/Intent.html).[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)is being used to identify the APK and the class of the watch face service.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|--------------------------------------------|
| `watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html) | The intent holding config activity launch. |

|                                            Returns                                             |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`?` | the value of an item previously added with[putWatchFaceComponentExtra](https://developer.android.com/reference/kotlin/androidx/wear/remote/interactions/WatchFaceConfigIntentHelper#putWatchFaceComponentExtra(android.content.Intent,android.content.ComponentName)), or null if no value was found. |

### putPeerIdExtra

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

```
fun putPeerIdExtra(watchFaceIntent: Intent, peerId: String): Intent
```

This method is adding the ID of the currently connected device to the given[Intent](https://developer.android.com/reference/android/content/Intent.html).  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html) | The intent holding config activity launch.               |
| `peerId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)      | The string representing peer ID to be added as an extra. |

### putWatchFaceComponentExtra

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

```
fun putWatchFaceComponentExtra(
    watchFaceIntent: Intent,
    componentName: ComponentName
): Intent
```

This method is for adding the extended data of watch face[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)to the given[Intent](https://developer.android.com/reference/android/content/Intent.html).  

|                                                  Parameters                                                  |
|--------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `watchFaceIntent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)             | The intent holding config activity launch.                    |
| `componentName: `[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html) | The component name of the watch face to be added as an extra. |