0

I want to remap the power button to show a custom system dialog / alert dialog instead of turning the screen off and on. I've looked at the Button Remapper apps but haven't seen any way I can do it. I want to do it without making a custom ROM but I'm not sure if it's possible.

How do you remap the power button event to show a system dialog / alert dialog?

IIIIIIIIIIIIIIIIIIIIII
  • 3,918
  • 4
  • 38
  • 63
John61590
  • 1,066
  • 1
  • 12
  • 26

1 Answers1

0

The Power button cannot be remapped neither by Button Remapper (I just read its description where there is a list of remappable buttons). Few buttons need Root Permissions to be remapped because you need to override System behaviour.

So I don't think it's possibile to remap the Power button because it's used to power on/off the screen and nothing else.

emandt
  • 1,903
  • 2
  • 10
  • 15
  • well, i know it's not possible to show the dialog using those apps so I don't consider them too much. Maybe looking for a more Android source answer. – John61590 Jul 24 '18 at 23:28
  • It is NOT possibile in a normal App. There are other metthods but involves other things more than an App (a quick Google search should were easy to do about it). The best one is creating an Xposed Module. Link_1: http://whitfin.io/remap-the-android-power-button/ Link_2: https://www.makeuseof.com/tag/improve-functionality-android-power-button/ – emandt Jul 24 '18 at 23:32
  • Remapping PowerButton is one of the most dangerous things for a device because it could prevent the device to wakeup from sleep or go in sleep-mode....for this reason there isn't any direct or easy way to do it. – emandt Jul 24 '18 at 23:34
  • I have a LOT of permission / freedom since I have signature-level permission and root. I understand changing the kl file but how does that help me show a dialog? – John61590 Jul 24 '18 at 23:44
  • There isn't any API neither for signature-level to manage the PowerButton. Permissions does nothing in some case if there is'nt any interface to use via software/API. The only solution is to intercept the call of the method that triggers the normal AlertDialog of Reboot, and then executes your method. Only XPosed Framework could do this because it interceps all system and method call. – emandt Jul 24 '18 at 23:50
  • well, which module would you recommend on Xposed? – John61590 Jul 24 '18 at 23:54
  • "Xposed Additions" seems to be the only one that is doing what you need. – emandt Jul 24 '18 at 23:58