Trigger: Power Button Toggle
The Power Button Toggle trigger fires when the power button is toggled (pressed) the specified number of times in quick succession. Since direct power button detection is not possible on Android, the trigger works by detecting screen on/off events as a proxy for power button presses.
Options
Number of Presses
- 3 - Fire when the power button is toggled 3 times
- 4 - Fire when the power button is toggled 4 times
- 5 - Fire when the power button is toggled 5 times
Examples
Example 1: Emergency SOS with 5 power button presses
Triggers Power Button Toggle (5)
Actions Send SMS: Emergency contact - SOS sent from [location] Enable GPS Force Location Update
Example 2: Toggle silent mode with 3 power button presses
Triggers Power Button Toggle (3)
Actions If ringer_mode = silent Set Ringer Mode: Normal Else Set Ringer Mode: Silent End If
How It Works
Since Android does not provide a direct way to detect power button presses, this trigger counts screen on/off events as a proxy measurement. Each press of the power button toggles the screen between on and off states, and the trigger counts these transitions.
Notes
- Device compatibility may vary - some devices may not register button presses reliably
- Users may need to space out individual presses with brief delays to ensure the trigger properly recognizes and registers each press
- The trigger requires the screen to actually turn on and off with each press, so press timing matters
- Very fast presses may be missed if the screen doesn't have time to fully transition between states
- This trigger can be used even when the device is locked
- The trigger listens for ACTION_SCREEN_ON and ACTION_SCREEN_OFF broadcast events
See Also