Google is committed to advancing racial equity for Black communities. See how.

TestWearableButtonsProvider

open class TestWearableButtonsProvider : WearableButtonsProvider
kotlin.Any
   ↳ androidx.wear.input.testing.TestWearableButtonsProvider

A WearableButtonsProvider suitable for use in tests.

This allows for explicitly specifying which buttons are available for testing, and their coordinates. It is intended to be used by passing in a map, mapping between the button keycode (typically in the set android.view.KeyEvent#KEYCODE_STEM_PRIMARY, , android.view.KeyEvent#KEYCODE_STEM_2, or ) and the location of the button. Take the following example:

Map<integer, testwearablebuttonlocation>
  buttons = new HashMap&lt;&gt;();
      buttons.put(KEYCODE_STEM_1, new TestWearableButtonLocation(100, 100);
 
      TestWearableButtonsProvider provider = new TestWearableButtonsProvider(buttons);
 
      WearableButtons.setWearableButtonsProvider(provider);
  
</integer,>

Summary

Nested classes
open

Class describing the location of a button on a wearable device.

Public constructors

Build a button provider, which will respond with the provided set of buttons.

Public methods
open IntArray?

open Bundle
getButtonInfo(@NonNull context: Context, keycode: Int)

Public constructors

<init>

TestWearableButtonsProvider(@NonNull buttons: MutableMap<Int!, TestWearableButtonsProvider.TestWearableButtonLocation!>)

Build a button provider, which will respond with the provided set of buttons.

Parameters
buttons MutableMap<Int!, TestWearableButtonsProvider.TestWearableButtonLocation!>: The buttons returned by this provider.

Public methods

getAvailableButtonKeyCodes

@Nullable open fun getAvailableButtonKeyCodes(@NonNull context: Context): IntArray?

getButtonInfo

@NonNull open fun getButtonInfo(
    @NonNull context: Context,
    keycode: Int
): Bundle