I am trying to develop an app that would do something after clicking the power button.
I have a code that catches the onClick of Power button, but it don’t seem to work. The screen would lock.
Now I am trying to catch the onLongPress of the Power Button, preventing the “Power Off” options from appearing. Any suggestions on how to do that?
thanks in advance.
hi your just trying to get notifed of the event than as Kartik pointed out you just need play around with the onKeyDown Event.
but form what I understand of your question you actually want to prevent the behavior of the power button and that can’t be done.
just like the home button pressed some events in android can’t be prevented to avoid people having apps they can’t quit.