Changes

no edit summary
Line 1: Line 1: −
<pre style="background-color: #EEEEEE; color: Black; border-radius: 10px; padding: 10px;">
+
<pre class="header-style">The Intent Received trigger fires when an intent with the specified action is broadcast by another application. This allows MacroDroid to respond to system events and inter-app communication through Android's intent mechanism. You can pattern match against extra parameter values and store these values into variables.</pre>
This trigger will fire when an intent with the specified action is fired by another application.
     −
You can also pattern match against one or more extra parameter values, as well as store these values into variables.
+
''' Options '''
</pre>
     −
'''Example Usage'''<br/>
+
* '''Action''': The intent action string to listen for (e.g., "android.intent.action.BATTERY_LOW" or a custom action from another app).
   −
<pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
+
* '''Extras''': Optionally configure one or more extra parameters to match:
Triggers
+
** '''Parameter Name''': The name/key of the intent extra to check
 +
** '''Value''': The pattern to match against (supports wildcards)
 +
** '''Variable''': Optionally store the extra's value into a string variable with optional dictionary keys
    +
* '''Enable Regex''': When enabled, value patterns are treated as regular expressions instead of wildcard patterns.
   −
</pre><br>
+
''' Examples '''
<pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
  −
Actions
      +
''Example 1: Respond to Custom App Intent''
 +
  <pre class="trigger-style">Triggers
   −
</pre><br>
+
Intent Received - com.example.app.CUSTOM_EVENT</pre>
<pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
+
  <pre class="action-style">Actions
Constrains
      +
Popup Message - Custom event received!</pre>
   −
</pre><br>
+
Triggers when another app broadcasts the custom intent "com.example.app.CUSTOM_EVENT".
<pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
  −
Local variables
      +
''Example 2: Capture Intent Extra into Variable''
 +
  <pre class="trigger-style">Triggers
   −
</pre><br>
+
Intent Received - com.example.app.DATA_UPDATE
 +
  Extra: data_value = * (save to: received_data)</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Popup Message - Received: {v=received_data}</pre>
 +
 
 +
Captures the "data_value" extra from the intent and stores it in a variable.
 +
 
 +
''' Notes '''
 +
 
 +
* Intent actions are case-sensitive strings.
 +
* Common system intent actions can be found in Android documentation.
 +
* The wildcard character (*) can be used in value patterns to match any content.
 +
* Multiple extra parameters can be configured, each with their own pattern and variable.
 +
* Each intent action is registered only once, even if multiple macros use the same action - MacroDroid efficiently shares the broadcast receiver.
 +
* Supports both local and global variables for storing extra values.
 +
* Dictionary keys can be specified when saving to array/dictionary variables.
 +
 
 +
''' Common Intent Actions '''
 +
 
 +
* <code>android.intent.action.BATTERY_LOW</code> - Battery is low
 +
* <code>android.intent.action.BATTERY_OKAY</code> - Battery is okay
 +
* <code>android.intent.action.POWER_CONNECTED</code> - Power connected
 +
* <code>android.intent.action.POWER_DISCONNECTED</code> - Power disconnected
 +
* <code>android.provider.Telephony.SMS_RECEIVED</code> - SMS received
 +
* <code>android.intent.action.PACKAGE_ADDED</code> - App installed
 +
 
 +
''' See Also '''
 +
 
 +
* [[Action:_Send_Intent|Send Intent Action]]