# WearableButtons

Summary:[Nested Classes](https://developer.android.com/reference/android/support/wearable/input/WearableButtons#nestedclasses)\|[Methods](https://developer.android.com/reference/android/support/wearable/input/WearableButtons#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/wearable/input/WearableButtons#inhmethods)  

# WearableButtons

`
public

final

class
WearableButtons
`  
`

extends `[Object](http://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|------------------------------------------------|
| [java.lang.Object](http://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.wearable.input.WearableButtons |

<br />

*** ** * ** ***

<br />

**This class is deprecated.**   
use`androidx.wear.input.WearableButtons`provided by the[Jetpack Wear Input](https://developer.android.com/jetpack/androidx/releases/wear)library instead.

Class containing helpers for managing wearable buttons.

## Summary

|                                                                                                                                                          ### Nested classes                                                                                                                                                          ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html) *This class is deprecated. use`androidx.wear.input.WearableButtons`provided by the[Jetpack Wear Input](https://developer.android.com/jetpack/androidx/releases/wear)library instead.* |

|                                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                                  ||
|------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static int`                                                                                                                                  | ` `[getButtonCount](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.html#getButtonCount(android.content.Context))`(`[Context](http://developer.android.com/reference/android/content/Context.html)` context) ` Get the number of hardware buttons available.                                                                                                                                                                 |
| ` static `[Drawable](http://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                           | ` `[getButtonIcon](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.html#getButtonIcon(android.content.Context,%20int))`(`[Context](http://developer.android.com/reference/android/content/Context.html)` context, int keycode) ` Returns an icon that can be used to represent the location of a button.                                                                                                                     |
| ` static `[WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html) | ` `[getButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.html#getButtonInfo(android.content.Context,%20int))`(`[Context](http://developer.android.com/reference/android/content/Context.html)` context, int keycode) ` Returns a[WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html)containing the metadata for a specific button. |
| ` static `[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)                                                   | ` `[getButtonLabel](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.html#getButtonLabel(android.content.Context,%20int))`(`[Context](http://developer.android.com/reference/android/content/Context.html)` context, int keycode) ` Returns a CharSequence that describes the placement location of a button.                                                                                                                 |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](http://developer.android.com/reference/java/lang/Object.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` `[Object](http://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                               | | ` boolean`                                                                         | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                            | ` finalize() `                                                                            | | ` final `[Class](http://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                            | | ` int`                                                                             | ` hashCode() `                                                                            | | ` final void`                                                                      | ` notify() `                                                                              | | ` final void`                                                                      | ` notifyAll() `                                                                           | | ` `[String](http://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                            | | ` final void`                                                                      | ` wait(long arg0, int arg1) `                                                             | | ` final void`                                                                      | ` wait(long arg0) `                                                                       | | ` final void`                                                                      | ` wait() `                                                                                | ||

## Public methods

### getButtonCount

```
public static int getButtonCount (Context context)
```

Get the number of hardware buttons available. This function only works on API level 24 or higher (Wear 2.0). This count includes the primary stem key as well as any secondary stem keys available.

<br />

|                            Parameters                            ||
|-----------|-------------------------------------------------------|
| `context` | `Context`: The context of the current activity <br /> |

|                                    Returns                                    ||
|-------|------------------------------------------------------------------------|
| `int` | The number of buttons available or -1 if not a Wear 2.0 device. <br /> |

### getButtonIcon

```
public static Drawable getButtonIcon (Context context, 
                int keycode)
```

Returns an icon that can be used to represent the location of a button.

<br />

|                                      Parameters                                      ||
|-----------|---------------------------------------------------------------------------|
| `context` | `Context`: The context of the current activity <br />                     |
| `keycode` | `int`: The keycode associated with the hardware button of interest <br /> |

|                                                                                   Returns                                                                                   ||
|--------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [Drawable](http://developer.android.com/reference/android/graphics/drawable/Drawable.html) | A drawable representing the location of a button, or null if unavailable <br /> |

### getButtonInfo

```
public static WearableButtons.ButtonInfo getButtonInfo (Context context, 
                int keycode)
```

Returns a[WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html)containing the metadata for a specific button.

The location will be populated in the following manner:

- The provided point will be on the screen, or more typically, on the edge of the screen.
- The point won't be off the edge of the screen.
- The location returned is a screen coordinate. 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.

Common keycodes to use are[KeyEvent.KEYCODE_STEM_PRIMARY](http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_STEM_PRIMARY),[KeyEvent.KEYCODE_STEM_1](http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_STEM_1),[KeyEvent.KEYCODE_STEM_2](http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_STEM_2), and[KeyEvent.KEYCODE_STEM_3](http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_STEM_3).

<br />

|                                      Parameters                                      ||
|-----------|---------------------------------------------------------------------------|
| `context` | `Context`: The context of the current activity <br />                     |
| `keycode` | `int`: The keycode associated with the hardware button of interest <br /> |

|                                                                                                                                                                                   Returns                                                                                                                                                                                   ||
|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html) | A[WearableButtons.ButtonInfo](https://developer.android.com/reference/android/support/wearable/input/WearableButtons.ButtonInfo.html)containing the metadata for the given keycode or null if the information is not available <br /> |

### getButtonLabel

```
public static CharSequence getButtonLabel (Context context, 
                int keycode)
```

Returns a CharSequence that describes the placement location of a button. An example might be "Top right" or "Bottom".

<br />

|                                      Parameters                                      ||
|-----------|---------------------------------------------------------------------------|
| `context` | `Context`: The context of the current activity <br />                     |
| `keycode` | `int`: The keycode associated with the hardware button of interest <br /> |

|                                                                          Returns                                                                          ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html) | A CharSequence describing the placement location of the button <br /> |