Tasker 'Send Intent' action - Help/Guide

5,534 views
Skip to first unread message

Badhri Narayanan

unread,
Oct 19, 2013, 4:47:48 PM10/19/13
to tas...@googlegroups.com
Hi All,


I have put together few examples of the Send Intent action with small explanation and lot of other references in the above link. Oh, and also a sample Project containing Send Intent actions, for reference.

I'm relatively new to both Tasker and Intents. When I started digging deep into these two, I had to search hours for these things(Google and this Tasker-Google Groups), and after sometime I had unwittingly made a small group of Google Keep notes, for Intents alone. So I thought of sharing this with everyone, in the hope that some day, some newbie would find it useful. I thought of posting it here directly, but due to the limited editing options of Google Groups, I ended up posting it in XDA forum.

If you feel that this is useful, do share it. Any corrections/additions/clarifications/outlashes;) are always welcome :) I'll try my best to keep that thread updated. If you have something to add on that thread, do let me know. I have attached the project file here as well, in case someone needs it. Remember, do not execute any Task directly. This is just for your reference.Copy the action to your own task and use it after editing.

Thanks to all the members of this amazing Tasker group - almost all my knowledge on Tasker and Intents, is based on searching this group for info.

Badhri
Intents.prj.xml

Raymond Cool

unread,
Oct 19, 2013, 4:58:46 PM10/19/13
to tas...@googlegroups.com

VERY VERY COOL! I'll revisit the page soon to apply my thanks

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.

Bob Hansen

unread,
Oct 19, 2013, 5:12:46 PM10/19/13
to tas...@googlegroups.com
Thank you Badhri!

This is the best source of information that I have seen on intents. 

I really appreciate it.

Thanks again,

bob

Brandon Horwath

unread,
Oct 20, 2013, 12:23:53 AM10/20/13
to tas...@googlegroups.com
+1

... and thank you.

but, can you explain this statement more?

Badhri Narayanan

unread,
Oct 20, 2013, 2:07:12 AM10/20/13
to tas...@googlegroups.com
The project file(the one attached in first post), contains 6 Tasks and nothing else. Each task contains few Send Intents, one after the other. If we run the Task(by clicking the Play icon) like we usually do, then I do not think it'll serve any purpose. For example, after importing the project if you open the Task 'Evernote', it'll contain all the Evernote related intents like creating a new note, opening a note, etc. If we just execute the Task, it'll do everything at once. The best thing one can do is to copy the action, say Send Intent for creating a new note, and paste it in a task of his/her own, where it could be put to good use after editing. Besides, I think I have added a Stop action at the start of every Task to prevent this(in case some one clicks on execute Task accidentally).

If someone has to put in a new Send Intent action in their task, and say they do not know how to put in the extra in correct format, they could refer to these actions and see if it could help them in any way. 

By,"Remember, do not execute any Task directly. This is just for your reference.Copy the action to your own task and use it after editing.", I meant these things.

Hope this explains(do forgive me if you find my English somewhat misleading).

Thanks,
Badhri

Eyal

unread,
Oct 20, 2013, 8:35:36 AM10/20/13
to tas...@googlegroups.com
Great project!

How about WhatsApp?
There are a few threads on stackoverflow on how to send a message throught WhatsApp, but I couldn't figure out how to apply it in Tasker.
For example:
public void onClickWhatsApp(View view) {

    Intent waIntent = new Intent(Intent.ACTION_SEND);
    waIntent.setType("text/plain");
            String text = "YOUR TEXT HERE";
    waIntent.setPackage("com.whatsapp");
    if (waIntent != null) {
        waIntent.putExtra(Intent.EXTRA_TEXT, text);//
        startActivity(Intent.createChooser(waIntent, "Share with"));
    } else {
        Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
                .show();
    }

}
What goes where in order to send a predefined message?

Thanks
בתאריך יום ראשון, 20 באוקטובר 2013 09:07:12 UTC+3, מאת Badhri Narayanan:

Badhri Narayanan

unread,
Oct 20, 2013, 4:00:52 PM10/20/13
to tas...@googlegroups.com
First of all, Thanks everyone for the encouraging words !


How about WhatsApp?

Hi Eyal,
In the above thread's Post#2, there is a section named "Share And Browse Intent". It might be of interest to you.(Particularly, the first three examples under that). You just have to tweak the package name. I believe for whatsapp it is "com.whatsapp"
 
There are a few threads on stackoverflow on how to send a message throught WhatsApp, but I couldn't figure out how to apply it in Tasker.
For example:
public void onClickWhatsApp(View view) {

    Intent waIntent = new Intent(Intent.ACTION_SEND);
    waIntent.setType("text/plain");
            String text = "YOUR TEXT HERE";
    waIntent.setPackage("com.whatsapp");
    if (waIntent != null) {
        waIntent.putExtra(Intent.EXTRA_TEXT, text);//
        startActivity(Intent.createChooser(waIntent, "Share with"));
    } else {
        Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
                .show();
    }

}
What goes where in order to send a predefined message?


But since you asked, I'll show you how this above piece of code gets transformed into a Tasker Send Intent action. (I'm not a Java programmer, but anyway I'll give it a try)

Intent waIntent = new Intent(Intent.ACTION_SEND);
  => This code intializes a new Intent of type "Intent.ACTION_SEND"
  => This part of code goes into the Tasker Send Intent action's 'Action' field.
  => The value in the action field should not be "Intent.ACTION_SEND". It should rather be "android.intent.action.SEND". The reason "Intent.ACTION_SEND" is a Java constant and it'll finally get replaced(internally) with the value "android.intent.action.SEND". And how did I come up with this ? From here.

waIntent.setType("text/plain");
  => Piece of cake. Whatever is in setType goes into Tasker's Mime Type field.

String text = "YOUR TEXT HERE";
waIntent.putExtra(Intent.EXTRA_TEXT, text);
  => This is the message which you are going to share
  => As the function name 'putExtra' suggests, it goes into the Tasker's Extra field
  => Again, like "Intent.ACTION_SEND", "Intent.EXTRA_TEXT" will get resolved to "android.intent.extra.TEXT". Again refer the same official Android Intents page.
  
waIntent.setPackage("com.whatsapp");
  => Tasker's Package field
  => If you do not specify this field's value in your Send Intent action, then it'll bring up all the apps with which you can share your message with.
  
startActivity(Intent.createChooser(waIntent, "Share with"));
  => Tasker's Target field => Activity
  
So your final Tasker Send Intent action should be something like this:

Send Intent [ 
 Action:android.intent.action.SEND 
 Cat:Default 
 Mime Type:text/plain 
 Data: 
 Extra:android.intent.extra.TEXT:YOUR TEXT HERE 
 Extra: 
 Package:com.whatsapp
 Class: 
 Target:Activity ]

I tested it and it works. But, you still have to tap on the contact with whom you are going to share the message with. So it is not fully input-free.

Badhri Narayanan

unread,
Oct 20, 2013, 4:06:22 PM10/20/13
to tas...@googlegroups.com
Sorry missed the hyperlinks in my previous post. 

  => The value in the action field should not be "Intent.ACTION_SEND". It should rather be "android.intent.action.SEND". The reason "Intent.ACTION_SEND" is a Java constant and it'll finally get replaced(internally) with the value "android.intent.action.SEND". And how did I come up with this ? From here.

And the other one,

Nat101

unread,
Oct 20, 2013, 7:34:50 PM10/20/13
to tas...@googlegroups.com
Cool.
Would you know if I can use Intent with Skype to launch and dial a specific contact?
Thanks;
nat

Brandon Horwath

unread,
Oct 21, 2013, 1:49:15 AM10/21/13
to tas...@googlegroups.com
Sounds like someone just volunteered to be a resident intent aficionado!

Badhri Narayanan

unread,
Oct 21, 2013, 3:27:27 PM10/21/13
to tas...@googlegroups.com
Yes I think you can.


I think, if you go through the discussion in this thread(plus skim through the above mentioned URLs), you'll be able to get it working.
(Sorry if you see another similar post. I did click on 'Post', but it mysteriously disappeared)

Badhri Narayanan

unread,
Oct 21, 2013, 3:31:29 PM10/21/13
to tas...@googlegroups.com
Haha.. Believe it or not. I do not use even a single intent in my routine Tasker tasks. I do not even know why started going through these things. ;) And since i do not use them and since I spent a lot of time learning this simple thing, I thought I might pass it on to others, so that it might be useful.

CazMaz

unread,
Jan 12, 2014, 9:52:47 PM1/12/14
to tas...@googlegroups.com
Hi all,

I screen captured the intent screen in an attempt to help those of us who are sometimes text impaired (I'm in this group on occasion).
I did alot of reading and also importing the posted profile, which was definitely helpful!
I then continued on into the dark world of intents.
The biggest problem I ran into was understanding the differences between URL,URN,URI encoding.
Most of us get the URL,URN, but not the URI(eye), so here's an example:

I used K9 as my Ginnie Pig.
This is using Tasker 1.6u2m, I don't think it's any different other than the cosmetics in 4+.

SendIntent (85)
A1: Send Intent [ Action:android.intent.action.SENDTO
Cat:Default
mime Type:
Data:mailto:som...@somedomain.com?subject=Test%20this&body=This%20is%20tedeous
Extra:
Extra:
Package:com.fsck.k9
Class: Target:Activity ]

There are a few things to note here.
1. The entry for the data: must be URI encoded, so spaces are %20, not + as in URL encoding.
2. You can use text/*, or text/plain for the mime type, but in this case, I left it blank.
3. Without the package name (com.fsck.k9), Android will bring up a chooser for the completion of the task to send the data, but with it, it brings up the compose screen pre-filled with the data.
4. No Extras needed in this case.
5. Target is Activity.

Here are the screen captures, I needed 2 in order to show the whole Intent entry layout.
I'm still learning this group interface, so, I hope the images turn out right.
Cazmaz

 

I hope this too, helps

I am still learning intents, but this is what I have so far.

There's another way to do these that includes using a format of /.EXTRA_NAME.

If anyone knows how to use this format to get to the extra information available form let's say the BatteryManager, an example would be great!

Cazmaz

francwalter

unread,
Dec 3, 2014, 11:19:54 AM12/3/14
to tas...@googlegroups.com
Am Montag, 13. Januar 2014 03:52:47 UTC+1 schrieb CazMaz:
Hi all ...

SendIntent (85)
A1: Send Intent [ Action:android.intent.action.SENDTO
Cat:Default
mime Type:
Data:mailto:som...@somedomain.com?subject=Test%20this&body=This%20is%20tedeous
Extra:
Extra:
Package:com.fsck.k9
Class: Target:Activity ]

There are a few things to note here.
1. The entry for the data: must be URI encoded, so spaces are %20, not + as in URL encoding.
2. You can use text/*, or text/plain for the mime type, but in this case, I left it blank.
3. Without the package name (com.fsck.k9), Android will bring up a chooser for the completion of the task to send the data, but with it, it brings up the compose screen pre-filled with the data.
4. No Extras needed in this case.
5. Target is Activity.
...

Thank you very much, this exactly what I hourly searched. Works charmingly in Tasker  4.6b5 at least.
Thank!

M@xF@ctor

unread,
Dec 12, 2014, 8:57:12 AM12/12/14
to tas...@googlegroups.com
please can you help me in shutting down wifi with a send intent action ?

Matt R

unread,
Dec 12, 2014, 2:23:09 PM12/12/14
to tas...@googlegroups.com
Why not just use the wifi off action built into Tasker (in the net category I think)?

Matt

M@xF@ctor

unread,
Dec 15, 2014, 3:59:45 AM12/15/14
to tas...@googlegroups.com
Thank you for the answer, but my ROM has some bug that breaks 3rd party apps like Tasker when shutting down wifi (if I use the Wireless Settings of Tasker or SecureSettings most of the times the wifi status hangs in a "shutting down" state forever, until phone hangs or restart by itself) so I must use the system way.

Anyway I have solved by launching the androd "wifi settings" from tasker and then by executing a tasker script with send event to simulate a keypress.
Reply all
Reply to author
Forward
0 new messages