Difference between revisions of "Action: Send Intent"
m |
Tag: Undo |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
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]. | 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]. | ||
− | = | + | A more readable description of what intent really is can also be found in this [https://en.wikipedia.org/wiki/Intent_%28Android%29?wprov=sfla1 Wikipedia article about Android intents]. |
− | + | ||
+ | = Input parameters = | ||
== Target == | == Target == | ||
Line 25: | Line 26: | ||
== Data (optional) == | == Data (optional) == | ||
− | The Data parameter in an intent allows you to specify additional information or data to be passed along with the intent. It can be used to provide context or instructions to the target activity, broadcast receiver, or service. The data can be passed in form of an URI ([https:// | + | The Data parameter in an intent allows you to specify additional information or data to be passed along with the intent. It can be used to provide context or instructions to the target activity, broadcast receiver, or service. The data can be passed in form of an URI ([https://en.wikipedia.org/wiki/Uniform_Resource_Identifier Uniform Resource Identifier]) which is just a string at its base. The URI can represent various types of data, such as a website URL, a file path, or a specific content URI. For example if you would want to open website https://example.com/ you would simply use <code>https://example.com/</code> as a data parameter. |
− | = | + | = Input parameter values = |
− | |||
− | + | 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. | 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. |
Latest revision as of 19:22, 7 February 2024
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.
A more readable description of what intent really is can also be found in this Wikipedia article about Android intents.
Input parameters
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)
The Data parameter in an intent allows you to specify additional information or data to be passed along with the intent. It can be used to provide context or instructions to the target activity, broadcast receiver, or service. The data can be passed in form of an URI (Uniform Resource Identifier) which is just a string at its base. The URI can represent various types of data, such as a website URL, a file path, or a specific content URI. For example if you would want to open website https://example.com/ you would simply use https://example.com/
as a data parameter.
Input parameter values
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...