| Line 1: |
Line 1: |
| − | <p><b>This trigger fires when an application is launched or closed.</b></p> | + | <pre class="header-style">The Application Launched/Closed trigger fires when an application becomes the foreground application (launched) or when it is no longer the foreground app (closed). This is useful for automating actions based on which app is currently in use.</pre> |
| | | | |
| − | ===<p><b>Magic Text</b></p>===
| + | ''' Options ''' |
| | | | |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | * '''Application Launched''' - Trigger fires when the selected application becomes the foreground app |
| − | This action supports the use of magic text, you can use it in the "Enter package name" option, you can manually define the package name if you know it or by extracting it from some previously defined variable, using the (...) button.
| + | * '''Application Closed''' - Trigger fires when the selected application is no longer the foreground app |
| − | It also has magic output text [app_name] and [app_package] </pre> [[Magic_text|More information on the associated magic text.]]
| |
| − | <br>
| |
| | | | |
| − | ===<p><b>Supported configurations</b></p>===
| + | ''' Application Selection ''' |
| | | | |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | After choosing the event type, you can specify which applications to monitor: |
| − | Force legacy mechanism:
| |
| − | Try this option if you have issues with the new application launched trigger implementation, or don't want to enable Accessibility access for MacroDroid.
| |
| | | | |
| − | Prevent notifications interfering:
| + | * '''Select Applications''' - Choose specific applications from a searchable list. Multiple apps can be selected. |
| − | Swiping down the status bar may interfere with this trigger. This option prevents this interference but may cause issues with the trigger on some devices.
| + | * '''Enter Package Name''' - Manually enter a package name. Supports magic text for dynamic package names. |
| | + | * '''All Applications''' - Trigger fires for any application launch/close (excluding MacroDroid itself and system UI) |
| | | | |
| − | More information about this:
| + | When selecting specific applications, you can: |
| | + | * Search for apps by name |
| | + | * Show non-launchable apps using the checkbox |
| | + | * Select multiple applications |
| | + | * Previously selected apps appear at the top of the list |
| | | | |
| − | Due to changes to Android, there is a faster method with the use of accessibility services, however it is still possible to avoid accessibility services by ticking the box 'force legacy system'
| + | ''' Settings ''' |
| − | Accessibility can be granted by following the steps in the popup or by pressing the notification that appears from MacroDroid.
| |
| − | Any other issues, please consult the Troubleshooting section under the left hamburger menu from the MacroDroid home screen.
| |
| − | </pre><br>
| |
| | | | |
| − | ===<p><b>Example Usage 1</b></p>===
| + | * '''Force legacy mode''' - Uses an older polling-based method instead of the Accessibility Service. This may be needed on some devices but is less efficient. When enabled, additional settings become available for API 21/22 compatibility. |
| | + | * '''Prevent notification interrupt''' - Available when using legacy mode on certain Android versions |
| | | | |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | ''' Magic Text ''' |
| − | When starting YouTube the screen rotation will be activated
| |
| − | </pre><br>
| |
| | | | |
| − | <pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
| + | When using the "Enter Package Name" option, you can use magic text to specify the package name dynamically. This allows for variable-based app detection. |
| − | Triggers
| |
| | | | |
| − | Application launched (YouTube)
| + | The trigger also provides context information including the app name and package name that can be used in subsequent actions. |
| − | </pre><br>
| |
| − | <pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Actions
| |
| | | | |
| − | Enable screen rotation.
| + | * {app_package} |
| − | </pre><br>
| + | * {app_name} |
| − | <pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Constraints
| |
| | | | |
| | + | ''' Examples ''' |
| | | | |
| − | </pre><br> | + | ''Example 1: Mute When Opening Video App'' |
| | + | <pre class="trigger-style">Triggers |
| | | | |
| − | ===<p><b>Example Usage 2</b></p>===
| + | Application Launched (YouTube)</pre> |
| | + | <pre class="action-style">Actions |
| | | | |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | Volume Change: Media Volume to 0</pre> |
| − | When closing YouTube the screen rotation will be deactivate
| |
| − | </pre><br> | |
| | | | |
| − | <pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;"> | + | ''Example 2: Lock Screen When Leaving Banking App'' |
| − | Triggers | + | <pre class="trigger-style">Triggers |
| | | | |
| − | Application closed(YouTube) | + | Application Closed (Banking App)</pre> |
| − | </pre><br> | + | <pre class="action-style">Actions |
| − | <pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;"> | |
| − | Actions | |
| | | | |
| − | Disable screen rotation.
| + | Screen Lock</pre> |
| − | </pre><br> | |
| − | <pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Constraints
| |
| | | | |
| | + | ''' Notes ''' |
| | | | |
| − | </pre>
| + | * By default, this trigger uses the Accessibility Service to detect foreground app changes, which is efficient and reliable |
| | + | * The legacy polling mode requires Usage Access permission on Android 5.1 (API 22) and above |
| | + | * When "Application Closed" macros are triggered, they are processed before "Application Launched" macros for the new foreground app |
| | + | * The trigger ignores soft input windows (keyboards) to avoid false triggers when the keyboard appears |
| | + | |
| | + | ''' Permissions Required ''' |
| | + | |
| | + | * '''Accessibility Service''' - Required for the default (non-legacy) mode |
| | + | * '''Usage Access''' - Required for legacy mode on Android 5.1+ |
| | + | |
| | + | ''' See Also ''' |
| | + | |
| | + | * [[Constraint:_Application_Running|Application Running Constraint]] |