I am developing a System App (i.e. an app signed with the device manufacturer's key) for non-rooted devices.
I need to prevent the user from shutting-down or rebooting the device.
If necessary and possible, disabling the power button completely would be a solution, though all I require is to be able to prevent the shut-down dialogue which appears when the power button is held-down.
You should be able to override the
KeyEventfor this action, which isKEYCODE_POWER. See this post:Power key event in android?
The important thing here is after you handle the
KeyEventyou need to returntrueto let the system know that it has been handled.