Line 1: |
Line 1: |
− | This action can be used to invoke an Android Intent. | + | 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 [[Action:_Launch_Application|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 [[Action:_Open_Website_/_HTTP_GET|Open Website]] action? It also uses intent to open the website. Do you know the [[Action:_Launch_Shortcut|Launch Shortcut]] action? |
| | | |
− | This feature is for advanced users who understand the details of the intent they wish to invoke.
| + | If you are not afraid of technical words and terms, you can also dive into [https://developer.android.com/reference/android/content/Intent official android developers' documentation]. |
| + | |
| + | = Parameter = |
| + | <hr> |
| + | |
| + | == 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 [https://developer.android.com/reference/android/app/Activity 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 [[Trigger:_Intent_Received|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 <code>android.intent.action</code>. For example, <code>android.intent.action.VIEW</code> is used to display a content of certain app or a web page. <code>android.intent.action.MAIN</code> is used to open a certain predefined activity of an app (for example opening MacroDroid template store search activity). Here is [https://developer.android.com/reference/android/content/Intent#standard-activity-actions a list of most common activity actions] and [https://developer.android.com/reference/android/content/Intent#standard-broadcast-actions 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 <code>com.arlosoft.macrodroid.templatestore.ui.search.TemplateSearchActivity</code>. |
| + | |
| + | == Data (optional) == |
| + | To be continued... |
| + | |
| + | = How should I know what parameter values to use? = |
| + | <hr> |
| + | |
| + | 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 [[Action:_Send_Intent#Examples|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 [https://play.google.com/store/apps/details?id=rk.android.app.shortcutmaker 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 = |
| + | <hr> |
| + | |
| + | To be continued... |