Google Drive Intent

2,179 views
Skip to first unread message

Leandro Preto

unread,
Aug 3, 2015, 3:48:31 PM8/3/15
to AndroidScript
Hello,

Well... i'm trying to use the "send intent" functionality to send some files to google drive;

As far as i read about, the files has to be inclued at the "extras" array.

Is it possible to:

- Send image files too?

- Send an array of files?

- Set the destination folder?


does someone have some examples or tips so i can proceed with my work?


Thanks!


This is what i have:
function intentMaps() {
var blob = new Blob([app.ReadFile( "/sdcard/Download/Arquivo.txt" )], {type: 'text/plain'});
var uriBlob = URL.createObjectURL(blob);

var packageName = "com.google.android.apps.docs";
var className = "com.google.android.apps.docs.shareitem.UploadSharedItemActivity";
var action = "android.intent.action.SEND";
var category = "android.intent.category.DEFAULT"
var uri = null;
var type = "*/*";
var extras = [{"name":"android.intent.extra.EXTRA_STREAM", "value":uriBlob}];
 
    app
.SendIntent(packageName, className, action, category, uri, type, extras);
}


Message has been deleted

sankarshan dudhate

unread,
Aug 8, 2015, 9:34:48 AM8/8/15
to AndroidScript
Hi Leandro,
You can refer to developer.android.com for a nice reference and examples on Andtoid Intents.

Cheers,
Sankarshan

Dave Smart

unread,
Aug 10, 2015, 6:32:07 AM8/10/15
to AndroidScript
Hi Leandro,

I'm not sure if the what you are trying is going to work, but please let us know if it does work :)

I would say that Google Drive functionality is a prime candidate for a DroidScript plugin... anyone fancy writing one?



Dave Smart

unread,
Aug 10, 2015, 7:30:42 AM8/10/15
to AndroidScript
Hi Leandro,

I've actually recently added an app.SendFile() method which prompts the user for an app to receive the file.  If this will do what you want, then let me know and you can try out the alpha version.

Regards
David

Dave Smart

unread,
Aug 10, 2015, 9:22:07 AM8/10/15
to AndroidScript
OK, I've being playing around with Google drive this morning and discovered that you can actually send text files using the current version of DroidScript and a modified version of Leandro's code :)

 Here it is:-

  var textData = "The cat sat on the mat";
    var packageName = "com.google.android.apps.docs";
    var className = "com.google.android.apps.docs.shareitem.UploadSharedItemActivity";
    var action = "android.intent.action.SEND";
    var category = "android.intent.category.DEFAULT"
    var uri = null;
    var type = "text/plain";
    var extras = [
        {name:"android.intent.extra.TEXT", type:"string", value:textData},
    ];
    
    extras = JSON.stringify( extras );
    app.SendIntent(packageName, className, action, category, uri, type, extras);



I've also added a new 'file' type option to the extras, so that you can also send file streams like images etc to Google Drive and Drop box too :)

Regards
David

Leandro Preto

unread,
Aug 21, 2015, 8:49:44 AM8/21/15
to AndroidScript
Hello Dave,

Sorry that i took long to respond, my work and studies are taking all my time.


First of all, thank you so much for your appreciation to my topic.


So, my app saves some json text files and images to device's sd_card, and i want to send them to a specific folder at my own google drive.

I was trying to learn about that google's oAuth2, but i'm running on circles on that.

So i was thinking i could use Android Intend to Drive as a shortcut.

I think your solution will definitely work for me.

I will send my images as base64 string. then i will convert then to files using Apps Script.


Thank you so much again!!

Guilherme Kruger

unread,
Aug 24, 2015, 4:54:12 PM8/24/15
to AndroidScript
Hello Dave,

I've also been trying to send a file with the Drive API, with text it sends just fine, but I'm not gettin it trough with the image.

Could you please share a working code with image uploading to Drive?

Thanks.

Steve Garman

unread,
Aug 24, 2015, 5:00:34 PM8/24/15
to AndroidScript
Guilherme,
my understanding of Dave's post is that this will not work until the next version of DroidScript is released, allowing the use of type:"file" in the extras.

If I am wrong, hopefully Dave will correct me.

Dave Smart

unread,
Aug 25, 2015, 7:25:40 AM8/25/15
to AndroidScript
Hi Guilherme, Yes Steve is right.  I will probably be releasing a new private beta this week, so if you are desperate for that functionality then you can sign up for the private beta program by sending us a request directly.

Reply all
Reply to author
Forward
0 new messages