在我的Android应用程序中,我希望防止卷更改,这意味着即使应用程序未运行,用户也无法更改设备的容量。请告诉我该怎么做?
答案 0 :(得分:0)
试试这个,
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)){
//Nothing
}
return true;
}
答案 1 :(得分:0)
试试这个
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP: //your code
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN: //your code
return true;
default:
return super.dispatchKeyEvent(event);
}
}