question

jasonbanks avatar image
jasonbanks asked Jeffrey Blattman commented

Power Button control/receiver?

Our application requires the terminal to be passed between an employee and customer, where the pressing of the power button can be easily done by accident. This question is compound;

1) Is there a broadcast that the power button is pressed? Standard onKeyPress does not work, as the button does not appear to identify as a PowerButton.

2) We use Customer Mode, is there a way to prevent the power button from turning the screen off?

Clover Android SDK
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jeffrey Blattman avatar image
Jeffrey Blattman answered Jeffrey Blattman commented

1. There are a few ideas here: https://stackoverflow.com/questions/25832380/android-detect-pressing-on-power-key. It'd help to know what you want to do that. I could speculate that you want to try and turn the screen back on when it's turned off. That might work, but could also depend on how the foreground app handles it.

2. No that is not possible. Customer mode will keep the screen from locking.

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jasonbanks avatar image jasonbanks commented ·
Thank you for the quick response. Perhaps that could be taken as a consideration for CUSTOMER MODE, that accidental pressing of the "power" button would not turn off the screen either.


Unfortunately I cannot capture the broadcast, because it doesn't get sent (tried same idea you posted). Could be that the button is not a true power button. Camera button works, that one didn't.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ jasonbanks commented ·
Take a look at the link I posted and note the answers that discuss registering to receive the screen off, on broadcasts.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community