In my recent post about run shell actions in Tasker I listed over 40 different shell commands to help you toggle settings on your Android device. There is one more way of forcing specific actions, especially within different applications. Android intents in Tasker are another way to communicate with applications by passing a command, that often consist an action and parameters to complete this action.
To illustrate how to find, compose and use intents, I will be using Google Keep app.
Intents – the construction
This is how intent is presented in the manifest.xml file. Since the file is present in nearly every app available out there, there is no need for a list itself, but a handy guide, how to find and use the intents with Tasker. If you want a list of most common intents Joao Dias has you covered here.
<intent-filter> <action android:name="com.google.android.gms.actions.CREATE_NOTE"> <category android:name="android.intent.category.DEFAULT"> <data android:mimeType="*/*"> </intent-filter>
This particular intent informs Google Keep that we are trying to CREATE NOTE, which has a DEFAULT category and is expecting any content (text/picture/etc) */*.
If you send this command manually, Keep is expected to open a new note, as if you clicked the appropriate button.
The app will populate the screen with all installed apps and services and we will be able to access the manifest by clicking on a selected app. In this example, I’m doing this with Keep. The file will load and all xml code will be available to be previewed and saved on your phone. At this point, I would also advise you to share this file (stored in a Manifest Viewer folder) and send it to your PC for easy manipulation. I use Join to share the content of my clipboard between the mobile and PC.
Intents are contained between <intent-filter>…</intent-filter> markup and if you are clever you can use Notepad++ or similar to use RegEx search to get you the content you need.
At this stage, all we need to do is to see what useful intents we have the access to. Most of the intents will leave you clues to what they suppose to do, as you have seen this in the create note example.
Android intents and Tasker
You can either use Tasker to send an intent or use a plugin of your choice. For the purpose of this write-up, I will show you how to use AutoShare and how to send android intents in Tasker.
An intent is one of the system actions in Tasker. Use of it will be pretty straight forward. Copy the relevant information from our code to sections of the tasker.
Action: com.google.android.gms.actions.CREATE_NOTE Cat: android.intent.category.DEFAULT Mime type: */* Package name: com.google.android.keep Extra: android.intent.extra.TEXT: test message Target: Action
As you have noticed, we had to include our text as an extra intent to pass our text in the new note. Also by default Target is set to broadcast receiver, and we need to set this to action, as we are sending the action command. Tasker has entire help file explaining this little closer.
Extra intents refer to a type of data you can parse with the intended action. Here is a list of intents available:
Supplying the TITLE and TEXT to the CREATE_NOTE intent would assign a title and body of our note. The details of the available commands in intents can be found here, but don’t get too worried about this. Finding the intents in the manifest will be the main way of looking for complete commands available for each application. For most of the time, this will be a simple copy and paste job!
The easiest way to execute an intent in Tasker is to use AutoShare. Several of them are already available to be downloaded to your app through this website. There is also an intent builder page which is very handy! You can access it here.
Setting up the intent may be a little confusing at first, but I will try to explain how to make it work. To set up everything correctly we will need to open AutoShare, and add an android intent manually. You will be asked for a name etc, and an entry will be created. Once you have it on your list, please log tap on the intent to reveal configuration menu.
From code listed in xml manifest, we have 3 types of data available for this intent.
Set Action: com.google.android.gms.actions.CREATE_NOTE Set Categories: android.intent.category.DEFAULT Set mime type: */* Also, we know our package name: com.google.android.keep
We have all the information entered now – time to go to Tasker and set up the AutoShare action. Obviously, in the App we going to pick Keep. Our Action will be the intent name you have created earlier. You will see all the intents available in a list. Then go to the advanced settings and set mime type to */*. Going back to the main screen you will also have Text entry, this is where you want to enter the text you wish to add to your note.
This is pretty much everything you need to do to get this to work. To check if action works correctly play the intent, then open your Keep app. You will see a new note created, containing the text you have entered in a text field.
Before I leave you to play with intents, just a few tips. Try to enter only information from the intent code alone, you will see that there are few more options available, however, most of the time you will only break the code itself. AutoShare does a good job of filling in the blanks.