简体   繁体   English

Android设备的音量键检测

[英]Volumns key detection for android device

Is there any way to detect the existence of the VOLUMN keys for android devices? 有什么方法可以检测android设备的VOLUMN键吗? Some features should be hidden if there no VOLUMN keys. 如果没有VOLUMN键,则应隐藏某些功能。 Appreciate for any help^.^ 感谢您的帮助^。^

For Volume Keys use KEYCODE_VOLUME_DOWN and KEYCODE_VOLUME_UP 对于音量键,请使用KEYCODE_VOLUME_DOWN和KEYCODE_VOLUME_UP

@Override
 public boolean onKeyLongPress(int keyCode, KeyEvent event) {
     if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 
     {
       // to your stuff here
       return true;
     }
 return super.onKeyLongPress(keyCode, event);
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM