# DeviceWearableButtonsProvider

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

*** ** * ** ***


```
class DeviceWearableButtonsProvider : WearableButtonsProvider
```

<br />

*** ** * ** ***

Default implementation of `https://developer.android.com/reference/kotlin/androidx/wear/input/WearableButtonsProvider`, that reads the button locations from the platform.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/input/DeviceWearableButtonsProvider#DeviceWearableButtonsProvider()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/wear/input/DeviceWearableButtonsProvider#getAvailableButtonKeyCodes(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Get the keycodes of available hardware buttons on device. |
| `https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/kotlin/androidx/wear/input/DeviceWearableButtonsProvider#getButtonInfo(android.content.Context,int)(context: https://developer.android.com/reference/android/content/Context.html, keycode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a bundle containing the metadata of a specific button. |

## Public constructors

### DeviceWearableButtonsProvider

Added in 1.0.0

```
DeviceWearableButtonsProvider()
```

## Public functions

### getAvailableButtonKeyCodes

```
fun getAvailableButtonKeyCodes(context: Context): Array<Int>?
```

Get the keycodes of available hardware buttons on device. This function based on key's locations from system property. This count includes the primary stem key as well as any secondary stem keys available.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The context of the current activity |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>?` | An int array of available button keycodes, or null if no keycodes could be read. |

### getButtonInfo

```
fun getButtonInfo(context: Context, keycode: Int): Bundle
```

Returns a bundle containing the metadata of a specific button. Currently, only location is supported. Use with and . The key will not be present if the information is not available for the requested keycode.

The location returned is a Cartesian coordinate where the bottom left corner of the screen is the origin. The unit of measurement is in pixels. The coordinates do not take rotation into account and assume that the device is in the standard upright position.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The context of the current activity |
| `keycode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The keycode associated with the hardware button of interest |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html` | A `https://developer.android.com/reference/android/os/Bundle.html` containing the metadata for the given keycode |