Skip to content

Global Action

Summary

  • Internal name: GlobalAction
  • Category: Android UI
  • Purpose: Trigger a system-level accessibility action (back, home, recent apps, screenshot, lock screen, etc.) via the Android AccessibilityService.
  • Task type: Normal

Compatibility

  • Minimum AndroMate version: 1.1.0
  • Maximum AndroMate version: 1.1.0
  • Minimum Android: Android 13 (API 33)
  • Maximum Android tested: Android 16 (API 36)
  • Supported manufacturers:

    • Samsung (One UI 6.x / 7.x / 8.x)
    • Other manufacturers - not supported yet (Xiaomi HyperOS and Google Pixel are being adapted)
    • Required permissions:
    • ACCESSIBILITY_SERVICE - the AndroMate accessibility service must be enabled in system settings

Detailed description

The Global Action task is one of the actions split out of the deprecated combined ScreenAutomator task (see Screen Automator). It calls AccessibilityService.performGlobalAction(int) through BaseControlService, which the task reaches directly via a static instance reference (BaseControlService.getInstance()) rather than a broadcast - the accessibility service must therefore already be connected (enabled by the user) when this task runs.

Each global action has its own minimum Android SDK requirement, independent of AndroMate's own compatibility range - see the action list in > Input parameter details.


Input parameters

Parameter Type Required Possible values Android Compatibility AndroMate Compatibility Default
GlobalAction_type Integer (resolvable) Yes Integer code of a supported global action - see table below Depends on the chosen action (16 -> 36) 1.1.0 -> 1.1.0 0

Output parameters

This task produces no output variable. It returns a VoidResult on success.


Exceptions

Code Exception Name Description
SCREEN-AUTOMATOR-ERROR-001 Invalid Control Service Global Action GlobalAction_type doesn't match any known action code.
SCREEN-AUTOMATOR-ERROR-002 Unsupported Control Service Global Action The action exists but requires a higher Android SDK than this device has.
SCREEN-AUTOMATOR-ERROR-010 Screen Automator Service Not Connected The AndroMate accessibility service isn't enabled/connected - enable it in system settings.
SCREEN-AUTOMATOR-ERROR-011 Screen Automator Action Failed performGlobalAction returned false (the action was refused by the system).

Execution flowchart

flowchart TD
    Start([GlobalAction]) --> CheckConnected{Accessibility service\nconnected?}
    CheckConnected -->|No| E1[SCREEN-AUTOMATOR-ERROR-010\nSERVICE_NOT_CONNECTED]
    CheckConnected -->|Yes| Resolve{GlobalAction_type\nmatches a known action?}
    Resolve -->|No| E2[SCREEN-AUTOMATOR-ERROR-001\nINVALID_GLOBAL_ACTION]
    Resolve -->|Yes| CheckSdk{Device SDK ≥\naction's minSdk?}
    CheckSdk -->|No| E3[SCREEN-AUTOMATOR-ERROR-002\nUNSUPPORTED_GLOBAL_ACTION]
    CheckSdk -->|Yes| Perform[performGlobalAction]
    Perform --> Done{Returned true?}
    Done -->|No| E4[SCREEN-AUTOMATOR-ERROR-011\nACTION_FAILED]
    Done -->|Yes| Success([VoidResult])

    E1 --> Error([Exception])
    E2 --> Error
    E3 --> Error
    E4 --> Error

    style Start fill:#e3f2fd
    style Success fill:#c8e6c9
    style Error fill:#ffcdd2
    style Perform fill:#fff9c4

How it works:

  1. Check connection: fails fast with SERVICE_NOT_CONNECTED if the accessibility service isn't enabled.
  2. Resolve the action: maps GlobalAction_type (an integer) to a known GlobalActionType.
  3. Check SDK: rejects the action if the device's Android version is below that action's minimum SDK.
  4. Perform: calls performGlobalAction; a false return throws ACTION_FAILED.

Code examples

Example 1 - Go back

{
  "GlobalAction": [
    { "id": "1", "title": "Go back", "GlobalAction_type": 1 }
  ]
}

Input parameter details

1. Input parameter: GlobalAction_type

Selects which system action to perform. Stored as an integer, resolvable from a $variable.

Logical name Description Android Global Action constant Min SDK
14 Show the launcher's "all apps" list GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS 31
11 Trigger the Accessibility button GLOBAL_ACTION_ACCESSIBILITY_BUTTON 31
12 Open the Accessibility button chooser menu GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER 31
13 Trigger the Accessibility shortcut GLOBAL_ACTION_ACCESSIBILITY_SHORTCUT 31
1 Navigate back GLOBAL_ACTION_BACK 16
15 Dismiss the notification shade GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE 31
20 D-Pad center keyevent GLOBAL_ACTION_DPAD_CENTER 33
17 D-Pad down keyevent GLOBAL_ACTION_DPAD_LEFT¹ 33
18 D-Pad left keyevent - 33
19 D-Pad right keyevent GLOBAL_ACTION_DPAD_RIGHT 33
16 D-Pad up keyevent GLOBAL_ACTION_DPAD_UP 33
2 Go home GLOBAL_ACTION_HOME 16
10 Send the KEYCODE_HEADSETHOOK key event GLOBAL_ACTION_KEYCODE_HEADSETHOOK 31
8 Lock the screen GLOBAL_ACTION_LOCK_SCREEN 28
22 Media play/pause (pending SDK 36) 22-36
21 Menu key event (pending SDK 36) 21-36
4 Open notifications GLOBAL_ACTION_NOTIFICATIONS 16
6 Open the power long-press dialog GLOBAL_ACTION_POWER_DIALOG 21
5 Open quick settings GLOBAL_ACTION_QUICK_SETTINGS 17
3 Overview / recent apps GLOBAL_ACTION_RECENTS 16
9 Take a screenshot GLOBAL_ACTION_TAKE_SCREENSHOT 28
7 Toggle split-screen (docking window) GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN 24

¹ Source enum data as of this writing; verify against GlobalActionType.java if a mismatch is suspected.

Example

"GlobalAction_type": 1

Output parameter details

This task has no output parameters.


Complete JSON example

{
  "GlobalAction": [
    { "id": "1", "title": "Go Home", "GlobalAction_type": 2 },
    { "id": "2", "title": "Open Notifications", "GlobalAction_type": 4 },
    { "id": "3", "title": "Take Screenshot", "GlobalAction_type": 9 }
  ]
}