Say to file -> open share popup to share it using another app. possible?

292 views
Skip to first unread message

Amir S.

unread,
Jan 25, 2014, 6:36:51 AM1/25/14
to tas...@googlegroups.com
im using the share function using the send intent and it works great for sharing text and links using another app from the popup window...


...how can i make the share button pull the last created file after using the 'say to file' action?

is there a variable that can tell the last file created in a spesific directory and then use it for the next action? (which is share in this case)


no plugins please lol



Thanks a lot for the support in advance!

Pent

unread,
Jan 25, 2014, 7:38:15 AM1/25/14
to tas...@googlegroups.com


...how can i make the share button pull the last created file after using the 'say to file' action?

I don't understand why you don't know which file you specified in the Say To File action, but:

Use a For action on the directory.


Task / For %thisfile, DIRECTORYHERE
Misc / Test, Modify Time, %thisfile, -> %thistime
Task / If %thistime > %mostrecenttime
   Variable Set, %mostrecenttime, %thistime
   Variable Set, %mostrecentfile, %thisfile
Task / EndIf

After that, the most recent file is in %mostrecentfile.

Pent

Amir S.

unread,
Jan 25, 2014, 7:17:11 PM1/25/14
to tas...@googlegroups.com
You done 80% of the job by creating for me a value of the recent file created in a specific directoory. THANKS!

Now it goes like this:
The task says to file a text from a dynamic value and then goes to a specific directory, the files names get to be:

Directory/%DATE-%TIME-%TIMES.wav

And thats in order to have different names for each file created and prevent overwrite to older files (unlike the 'take photo' action which give you an option to name files in a sequence automatically)


After its done the share popup will open to choose with which app and it will attach the audio file using send share intent and using:

MIME type: audio/*
Extra: directoory/%mostrecentfile


Now i'll implant this and comme with feedback unless you have any comment And again thanks for the great support!

Amir S.

unread,
Jan 28, 2014, 5:21:59 AM1/28/14
to tas...@googlegroups.com
Ok so when i press a button in a scene i created it does the following:

Save And Share (203)
A1: Flash [ Text:Saving and sharing... Long:Off ]
A2: Say To File [ Text:RandomText Engine:Voice:default:default File:VoiceDir/%DATE-%TIME-%TIMES.wav Pitch:5 Speed:5 Continue Task Immediately:Off ]
A3: For [ Variable:%thisfile Items:VoiceDir ]
A4: Test [ Type:File Modified Data:%thisfile Store Result In:%thistime ]
A5: If [ %thistime > %mostrecenttime ]
A6: Variable Set [ Name:%mostrecenttime To:%thistime Do Maths:Off Append:Off ]
A7: Variable Set [ Name:%mostrecentfile To:%thisfile Do Maths:Off Append:Off ]
A8: End If
A9: Flash [ Text:%mostrecentfile Long:Off ]
A10: Send Intent [ Action:android.intent.action.SEND Cat:Default
Mime Type:audio/*
Data:
Extra:VoiceDir/%mostrecentfile
Extra:
Package:
Class:
Target:Activity ]

But the value %mostrecentfile returns the value 'VoiceDir' which is the folder name rather than the actual file so nothing is added with the sharing function.... help please?


Thanks in advance.

Matt R

unread,
Jan 28, 2014, 12:37:22 PM1/28/14
to tas...@googlegroups.com
I think what's missing is a File -> List Files action before the For loop.  Have the output of the List Files action go to a variable like %dir_files and then in the For action, it will be For [ Variable:%thisfile Items:%dir_files() ].  Note the parentheses, they're important.

Matt

Amir S.

unread,
Feb 1, 2014, 5:26:29 AM2/1/14
to tas...@googlegroups.com
After adding your actions Matt the value %mostreccentfile returned back a list of all the files in that directory :/

..so i found another way to show the most recent file in value using 2 simple actions on a task:

Recentfile (207)
A1: List Files [ Dir:VoiceDir Match: Include Hidden Files:Off Variable:%Recentfile ]
A2: Array Process [ Variable:%Recentfile Type:Reverse ]


Thanks to the 'array proccess, reverse' action, the value %Recentfile1 is always the newest file but keep in mind its because they are alphabeticaly ordered thanks to the dynamic naming sequence i gave to them when they are created which is:
%DATE-%TIME-%TIMES.wav

So %Recentfile1 returns:
/storage/emulated/0/VoiceDir/2-1-2014-01.27-1391246872.wav

Now im trying to share it using the EXTRA.STREAM intent but it does not attach anything :/


Sharefile (201)
A1: Send Intent [ Action:android.intent.action.SEND Cat:Default
Mime Type:audio/*
Data: Extra:android.intent.extra.STREAM ,%lastfile1

Extra:
Package:
Class:
Target:Activity ]

I got the share intent working for plain text before but cant get it to work with file attachments; i know im just inputing a field incorrecrly but which one?

Please help.

Matt R

unread,
Feb 1, 2014, 9:44:41 PM2/1/14
to tas...@googlegroups.com
Try putting it in the extra field as:

android.intent.extra.STREAM:%lastfile1

Matt

Amir S.

unread,
Feb 2, 2014, 6:33:58 AM2/2/14
to tas...@googlegroups.com
I tried many veriation but no luck.


I put in the 'Extra' field:
android.intent.extra.STREAM: file:///mnt/sdcard/VoiceDir/filename
android.intent.extra.STREAM: /sdcard/Download/logo.png
android.intent.extra.STREAM: %lastfile1
android.intent.extra.STREAM: file:///%lastfile1

And a few more... tried with AND without the space after 'STREAM:'

I'm looking everywhere online for share intents but they are written differently when using actual coding.

This is from google'a tuturials for sharing a file maybe it will help:

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));


Is this really THAT complicated? :/

Amir S.

unread,
Feb 14, 2014, 7:14:37 AM2/14/14
to tas...@googlegroups.com
Bump...read message above for details.

Please help thanks!

Matt R

unread,
Feb 14, 2014, 1:30:06 PM2/14/14
to tas...@googlegroups.com
This worked for me for a picture:

A1: Send Intent [ Action:android.intent.action.SEND Cat:None Mime Type:image/jpeg Data: Extra:android.intent.extra.STREAM:file:///sdcard/DCIM/Camera/1387752731265.jpg Extra: Package: Class: Target:Activity ]

Matt

Message has been deleted

Amir S.

unread,
Feb 15, 2014, 7:40:05 AM2/15/14
to tas...@googlegroups.com
Tried exactly that with a path to a picture in my phone and its still not adding it as a file attachment both as a task or as an exported app....only sharing tezt works for me.

Using Android 4.2.


Sharefile (201)


A1: Send Intent [ Action:android.intent.action.SEND
Cat:None
Mime Type:image/jpeg
Data:

Extra:android.intent.extra.STREAM:file:///sdcard/Download/logo.jpg

Extra:
Package:
Class:
Target:Activity ]

What am i missing here?

Message has been deleted

Bob Hansen

unread,
Feb 15, 2014, 9:10:29 AM2/15/14
to tas...@googlegroups.com
Try this:

A1: Send Intent [ Action:android.intent.action.SEND 
Cat:None 
Mime Type:image/jpeg 
Data:file:///sdcard/Download/logo.jpg  
Extra:

Extra: 
Package: 
Class: 
Target:Activity ]

Amir S.

unread,
Feb 16, 2014, 4:09:00 AM2/16/14
to tas...@googlegroups.com
Tried that already. Anything that is in the 'data' field it puts in the 'to' field in email or gmail and when used with sms app it says 'cannot add content'.


Any ideas?

Matt R

unread,
Feb 16, 2014, 4:44:13 AM2/16/14
to tas...@googlegroups.com
Seems like this works of run in a root shell but not in Tasker's send intent action (without root, obviously). Maybe that's the issue.

Matt

Amir S.

unread,
Feb 16, 2014, 5:00:22 AM2/16/14
to tas...@googlegroups.com
Its an android share intent, has to work by implenting this correctly.

Is there another way to implant a file share task/action?

Bob Hansen

unread,
Feb 16, 2014, 9:05:15 AM2/16/14
to tas...@googlegroups.com
I used intent intercept to see what was sent when using ES file explorer to send a picture. It looks very much like what Matt did in a run shell with root. The difference is the FLAGS which grant permission to read the uri. Tasker's Send Intent action has no way to handle Flags. It might work in a Run Shell without root if the flags are specified in the command.

ACTION: android.intent.action.SEND
DATA: null
TYPE: image/jpeg

FLAGS:
FLAG_GRANT_READ_URI_PERMISSION
FLAG_ACTIVITY_FORWARD_RESULT
FLAG_ACTIVITY_PREVIOUS_IS_TOP

EXTRAS:
EXTRA 1:
Class: android.net.Uri$StringUri
Key: android.intent.extra.STREAM

Matt R

unread,
Feb 16, 2014, 4:12:05 PM2/16/14
to tas...@googlegroups.com
I tried it with the correct flag but without root and it gave the wrong user error. I'm not sure why it works with apps in general but not from Tasker without root.

Matt

Bob Hansen

unread,
Feb 16, 2014, 4:26:11 PM2/16/14
to tas...@googlegroups.com
I'm curious Matt, does the command with the flags set work in a terminal emulator?
Would you mind sharing the command you used?

Matt R

unread,
Feb 16, 2014, 10:24:28 PM2/16/14
to tas...@googlegroups.com
This is the shell command (with an arbitrary file path). Works as root user, but as a normal user it complains.

am start -a android.intent.action.SEND -t image/jpeg --eu android.intent.extra.STREAM file:///sdcard/DCIM/Camera/1391914473967.jpg --grant-read-uri-permission

Matt

Bob Hansen

unread,
Feb 17, 2014, 9:04:35 AM2/17/14
to tas...@googlegroups.com
Thanks Matt.

Last night I noticed that it seemed to work when the text message app was chosen as the destination but not the Gmail app. This morning I tried in a terminal emulator and adding -D for debugging which didn't show anything wrong. Seems like something changed because now it works with or without root and with or without the grant-read-uri-permission.

I am confused!

Amir S.

unread,
Feb 19, 2014, 12:09:45 PM2/19/14
to tas...@googlegroups.com
I will try this method Matt thanks!

..but can i add the permission when i export the app and keep using the 'send intent' action?

Looks like this is what was missing all this time...hmmm how do you write the permission for 'reading uri' when you export as an app?

Matt R

unread,
Feb 19, 2014, 12:27:09 PM2/19/14
to tas...@googlegroups.com
But it's more than just the "read URI" permission, it also has something to do with the user that calls it.  If you try the shell command (including the "read URI" flag) without root permission, it gives an error about being the wrong user.

Matt

Chris Ryan

unread,
Sep 29, 2015, 9:38:03 PM9/29/15
to Tasker
I have found a way to bypass the permissions and tags issue with tasker.

Instead of using a tasker intent, I have created a task which uses tasker Java functions.
These functions create a send intent and populate it with a file from the local filesystem.
It works, I have used it to share to google drive.
The link for my task is below.

Reply all
Reply to author
Forward
0 new messages