I need an ideal way to use the power button in the android. I have a code but it does not work and when running onKeyLongPress it works with the power button and the device is closed or restarted.. So what is your suggestion for this problem ?!
In the first I used it in the manifest file ..
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
Then I wrote the code at home..
@Override public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_POWER) {
// Do something here...
return true;
}
return super.onKeyLongPress(keyCode, event);
}
So what is the problem ?