- Android Wear Projects
- Ashok Kumar S
- 107字
- 2021-07-15 17:17:53
Multifunction buttons
In addition to the power button, Android Wear supports another button called the multifunction button on the device. The Wearable support library provides API for determining the multifunction buttons included by the manufacturer:
@Override
// Activity
public boolean onKeyDown(int keyCode, KeyEvent event){
if (event.getRepeatCount() == 0) {
if (keyCode == KeyEvent.KEYCODE_STEM_1) {
// Do stuff
return true;
} else if (keyCode == KeyEvent.KEYCODE_STEM_2) {
// Do stuff
return true;
} else if (keyCode == KeyEvent.KEYCODE_STEM_3) {
// Do stuff
return true;
}
}
return super.onKeyDown(keyCode, event);
}
Visit https://developer.android.com/training/wearables/ui/index.html for any sort of query that you might have on design guidelines for Wear device programming.