Android Question "pressy" power button management

aeropic

Active Member
Licensed User
Longtime User
Hi all,

I played a bit with the press-it (pressy like) application (see https://play.google.com/store/apps/details?id=com.incrediapp.press.it.macro.creator.time.saver )

This little app allows for instance to light the flash after a sequence of 3 presses on the power button.
Turning the flash ON or taking a pictures works even with a password protected device.

I wondered how this could work and searched the forum on the way to intercept "power button" presses. I've seen several threads and get the feeling it is impossible to intercept power button presses.

Thus my question, is ther a way to detect a power button press event with B4A ? Could we develop a service running in background just counting the number of presses ? Would this service be active even when the device is password protected locked ?

thanks
Alain
 

aeropic

Active Member
Licensed User
Longtime User
Humm, after an hour on this subject, I think I've understood the trick !

I found the keycodes.KEYCODE_xxx syntax which does the job for an activity, but I couldn't find a way to do this from a service.

==> they don't sense a button press, they sense the screen ON OFF event which is the result of a power button press ...
 
Last edited:
Upvote 0
Top