Want to Access Power Button events in android
i=0; public boolean onKeyDown(int keyCode, KeyEvent event) { System.out.println("In Key Down Method." + event.getKeyCode()); if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { i++; System.out.println("Power button pressed."); if (i == 2) { System.out.println("Power button pressed continuoulsy 3 times."); Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show(); } else { System.out.println("Power button pressed continuoulsy " + i + " times."); Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show(); } }