Changes

no edit summary
Line 1: Line 1: −
<pre class="header-style">
+
<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>
This trigger will fire when an application becomes the foreground application (launched) or when it is no longer the foreground app (closed).
  −
</pre>
     −
* ''When this trigger is present, you can use more [...]'' ''[https://macrodroidforum.com/wiki/index.php/Magic_text#Application_Launched.2FClosed magic text]''
+
''' Options '''
   −
<span style="color: #B22A2A; font-size: 24px; display: inline-block; margin-top: 15px; margin-bottom: 0px;"><strong>Supported configurations </strong></span>
+
* '''Application Launched''' - Trigger fires when the selected application becomes the foreground app
 +
* '''Application Closed''' - Trigger fires when the selected application is no longer the foreground app
   −
<span style="color: #B22A2A; font-size: 18px; display: inline-block; margin-top: 15px; margin-bottom: 15px;"><strong>App Launched/Closed </strong></span>
+
''' Application Selection '''
   −
They share the same options.
+
After choosing the event type, you can specify which applications to monitor:
* Select application(s): It will be activated when one or more applications are started or closed.
     −
* Enter package name: It will be activated when the application package is started or closed, you can get it from some variable or magic text [...]
+
* '''Select Applications''' - Choose specific applications from a searchable list. Multiple apps can be selected.
 +
* '''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)
   −
<span style="color: #B22A2A; font-size: 18px; display: inline-block; margin-top: 15px; margin-bottom: 15px;"><strong>Force legacy mechanism </strong></span>
+
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
   −
Try this option if you have issues with the new application launched trigger implementation, or don't want to enable Accessibility access for MacroDroid.
+
''' Settings '''
   −
<span style="color: #B22A2A; font-size: 18px; display: inline-block; margin-top: 15px; margin-bottom: 15px;"><strong>Prevent notifications interfering </strong></span>
+
* '''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
   −
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.
+
''' Magic Text '''
   −
<span style="color: #B22A2A; font-size: 18px; display: inline-block; margin-top: 15px; margin-bottom: 15px;"><strong>More information about this </strong></span>
+
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.
   −
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'
+
The trigger also provides context information including the app name and package name that can be used in subsequent actions.
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.
+
* {app_package}
 +
* {app_name}
 +
 
 +
''' Examples '''
 +
 
 +
''Example 1: Mute When Opening Video App''
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Application Launched (YouTube)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Volume Change: Media Volume to 0</pre>
 +
 
 +
''Example 2: Lock Screen When Leaving Banking App''
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Application Closed (Banking App)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Screen Lock</pre>
 +
 
 +
''' Notes '''
 +
 
 +
* 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 '''
 +
 
 +
* [[Trigger:_App_Install_Remove_Update|App Install/Remove/Update Trigger]]
 +
* [[Constraint:_Foreground_App|Foreground App Constraint]]