how to capture long press volume down key in android?

后端 未结 4 1241
暖寄归人
暖寄归人 2021-01-18 03:39

Just wondering whether anyone could tell me how to capture the long keypress of the volume down key in android.

Elaborated question:

I wanted to create a

4条回答
  •  甜味超标
    2021-01-18 04:25

    may be below code will help you:

    @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);
    }
    

提交回复
热议问题