-1

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.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
fadedbee
  • 42,671
  • 44
  • 178
  • 308

1 Answers1

0

You should be able to override the KeyEvent for this action, which is KEYCODE_POWER. See this post:

Power key event in android?

The important thing here is after you handle the KeyEvent you need to return true to let the system know that it has been handled.

Jim
  • 10,172
  • 1
  • 27
  • 36