I want to launch my app on pressing power and volume up button together. I am able to launch the app on volumeChange but the default increase/decrease of volume functionality is overrided. So, Can anyone let me know how to do with the combination of two buttons?
I am launching the app this way, which works fine.
Intent i = new Intent();
i.setClass(context, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Need help to handle on pressing keys event.
Thanks, Adheesh.
I've used this code to listen for the volume button before.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)){
//Do something
}
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With