WearableButtons
public
final
class
WearableButtons
extends Object
java.lang.Object | |
↳ | android.support.wearable.input.WearableButtons |
This class is deprecated.
use androidx.wear.input.WearableButtons
provided by the Jetpack Wear Input library instead.
Class containing helpers for managing wearable buttons.
Summary
Nested classes | |
---|---|
class |
WearableButtons.ButtonInfo
This class is deprecated.
use |
Public methods | |
---|---|
static
int
|
getButtonCount(Context context)
Get the number of hardware buttons available. |
static
Drawable
|
getButtonIcon(Context context, int keycode)
Returns an icon that can be used to represent the location of a button. |
static
WearableButtons.ButtonInfo
|
getButtonInfo(Context context, int keycode)
Returns a |
static
CharSequence
|
getButtonLabel(Context context, int keycode)
Returns a CharSequence that describes the placement location of a button. |
Inherited methods | |
---|---|
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.
Parameters | |
---|---|
context |
Context : The context of the current activity |
Returns | |
---|---|
int |
The number of buttons available or -1 if not a Wear 2.0 device. |
getButtonIcon
public static Drawable getButtonIcon (Context context, int keycode)
Returns an icon that can be used to represent the location of a button.
Parameters | |
---|---|
context |
Context : The context of the current activity |
keycode |
int : The keycode associated with the hardware button of interest |
Returns | |
---|---|
Drawable |
A drawable representing the location of a button, or null if unavailable |
getButtonInfo
public static WearableButtons.ButtonInfo getButtonInfo (Context context, int keycode)
Returns a WearableButtons.ButtonInfo
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
, KeyEvent.KEYCODE_STEM_1
, KeyEvent.KEYCODE_STEM_2
, and KeyEvent.KEYCODE_STEM_3
.
Parameters | |
---|---|
context |
Context : The context of the current activity |
keycode |
int : The keycode associated with the hardware button of interest |
Returns | |
---|---|
WearableButtons.ButtonInfo |
A WearableButtons.ButtonInfo containing the metadata for the given keycode or null if the
information is not available
|
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".
Parameters | |
---|---|
context |
Context : The context of the current activity |
keycode |
int : The keycode associated with the hardware button of interest |
Returns | |
---|---|
CharSequence |
A CharSequence describing the placement location of the button |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.