Action: Send Intent

Revision as of 10:54, 3 June 2023 by FrameXX (talk | contribs)

This action can be used to call an Android Intent. The Intent action is one of the more complex and powerful actions of MacroDroid. Do you know the Launch Application MacroDroid action? It uses intent to launch the application and can be replaced with a properly set intent action. Do you know the Open Website action? It also uses intent to open the website. Do you know the Launch Shortcut action?

If you are not afraid of technical words and terms, you can also dive into official android developers' documentation.

Parameter


Target

The target of an intent can be either Activity, Broadcast or Service. You will find yourself using the Activity and Broadcast options in almost all cases.

Activity intents are used to open a new UI for the user. Such a UI is generally called a activity in Android. To give an example, when you add an action to a MacroDroid macro, a new activity is always opened for you to select your desired action. With an activity intent, you can open a web page in your browser, or you can open a specific settings page, or an app uninstall dialogue, etc.

Broadcast Intents are used to send a message or other data to other applications on the phone. Some applications deliberately support invoking actions by broadcasting a certain intent, so that automation applications like Tasker, MacroDroid etc... can be used to control them. MacroDroid is also able to receive broadcast messages and messages or other data within them using the Intent Received trigger. Intents are not only sent by other applications, but many of them are also sent by system. For example, when the battery is low, when the boot is finished, when the battery percentage of a bluetooth device changes, etc...

Action

Intent action defines what kind of activity you are trying to open or what kind of information are you broadcasting. Most of the activity actions start with android.intent.action. For example, android.intent.action.VIEW is used to display a content of certain app or a web page. android.intent.action.MAIN is used to open a certain predefined activity of an app (for example opening MacroDroid template store search activity). Here is a list of most common activity actions and a list of most common broadcast actions

Package (optional)

Package in an activity intent defines which package will be used to open an activity. If the field is left empty the system will open the app able to handle the intent or it will show a picker to let the user choose which app to open the intent with. If there's no app to handle the intent, or the defined package is not able to handle the intent it will result in an error message from MacroDroid.

Package in a broadcast intent defines which package will be able to receive the broadcasted intent. If no package is defined the intent will be broadcasted globally to all packages.

Class (optional)

Class in an activity intent will define what predefined app activity to actually open. For example, in the beforementioned case of opening MacroDroid template search activity the class parameter would be com.arlosoft.macrodroid.templatestore.ui.search.TemplateSearchActivity.

Data (optional)

To be continued...

How should I know what parameter values to use?


I know. It's a complex mess. So how should you know what intent parameters to use when you want to quickly open Google Web search inside Google app? Some useful intents can be found online or in the Examples section of this article.

One of the most helpful things regarding this action I personally stumbled upon and can recommend is an app called Shortcut Maker. It provides a simple UI that allows you to discover all of the different activity intents that can be launched on the phone and tinker with their parameters as you please. You can either copy all of the parameters to the MacroDroid Send Intent action or use the MacroDroid Launch Shortcut action, choose Shortcut Maker and choose the activity intent using the app UI.

If an app allows for control (actions to be invoked) using broadcast intents, you can usually find the exact parameters in its documentation.

Examples


To be continued...