Power Button - Disable or alternative workarounds?

RandomCoder

Well-Known Member
Licensed User
Longtime User
I'm back trying my hand at some B4A programming and I've hit a snag with a Lone Working App that I've been working on for some time.
The app detects motion and/or screen presses to sense that a person is OK, if no motion or screen press has been detected within a pre-set time then a message is automatically sent requesting urgent assistance. All has been working well, until I was given two new phones to test the program on, namely the HTC Wildfire S.

The power button on these phones is along the top edge of the phone and VERY easy to press accidentally, and this is my problem! Once the power button is pressed I have no way of making my app active again although the services are still running and counting down to zero. My app is effectively useless as it no longer detects motion and also fails to send the emergency request until the power button is pressed again.

Is there any way to prevent the power button from sending the phone into sleep mode, or is there a work around that will 'wakeup' the phone and bring my activity back to the foreground?

I'm already using 'keepalive' and 'partiallock' and experimenting with a service module to call the main activity when the user navigates away from my app but I've been unable to fix the power button problem and after searching on the Forum for the last few hours it looks as though I'm out of luck. So I'm just hoping that maybe things have changed in recent months???

My only other option as I see it is to guard against the power button being accidentally pressed but that's very Heath Robinson and so I'd rather do something programmatically if at all possible?

Any ideas?
Thanks,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
@Erel,

Thank you for the reply. Could you please expand on what is meant by 'release the regular lock and aquire it again'?

I have a service running that calls the activity to ensure it maintains the focus over any other apps but this doesn't appear to work if the power button is briefly pressed. It will be my implementation that is wrong as normal ;)

Kind regards,
RandomCoder
 
Upvote 0
Top