Android 音量鍵增大減小捕捉:
@Override
public boolean onKeyDown(
int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
Intent i = new Intent(
Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
return true;
}
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
Toast.makeText(
Bengkui.this,
"彈出對話框", 1000)
.show();
Intent intent = new Intent(
Bengkui.this,
ShoujizhengrenActivity.class);
startActivity(intent);
return true;
}
else {
return super.onKeyDown(
keyCode, event);
}
}