DeviceWearableButtonsProvider
class DeviceWearableButtonsProvider : WearableButtonsProvider
Default implementation of WearableButtonsProvider, that reads the button locations from the platform.
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
IntArray<Int>? |
getAvailableButtonKeyCodes(context: Context)Get the keycodes of available hardware buttons on device. |
Bundle |
getButtonInfo(context: Context, keycode: Int)Returns a bundle containing the metadata of a specific button. |
Public constructors
Public functions
getAvailableButtonKeyCodes
fun getAvailableButtonKeyCodes(context: Context): IntArray<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: Context |
The context of the current activity |
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 X_KEY and Y_KEY. 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.