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

}

}

你可能感兴趣的:(Android 音量键增大减小捕捉)