Issue
I've created a simple notepad app which implements the ACTION_SEND share intent to share notes.
My data has the mime type of "text/plain" and Google Drive (formerly Google Docs) is offered as a choice on my device, when I select Google Drive I get the error "This item cannot be uploaded as Google Document" via a Toast message.
I create my share intent like this:
Intent share_intent = new Intent(android.content.Intent.ACTION_SEND);
share_intent.setType("text/plain");
share_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, name);
share_intent.putExtra(android.content.Intent.EXTRA_TEXT, content);
startActivity(share_intent);
Apps like Mail, Messaging, Twitter and Wordpress all seem to handle the intent well and share at least the EXTRA_TEXT content.
I wonder if there's a way that would allow Google Drive to successfully upload the note, or at least handle the intent better?
I'm new to Android so please forgive my stupidity if this turns out to be a stupid question. I'm developing against a minimum SDK version 15, if that helps at all.
Here's a screen-grab of the error message:
In LogCat I spotted the error message again:
05-13 23:31:46.906: E/UploadSharedItemActivity(14594): This item cannot be uploaded as Google Document.
There's also a warning which occurs before the error message:
05-13 23:31:46.250: W/ND(14594): Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Google Collections to your system class path.
05-13 23:31:46.250: W/ND(14594): java.io.FileNotFoundException: com/google/inject/internal/Finalizer.class
05-13 23:31:46.250: W/ND(14594): at NE.a(FinalizableReferenceQueue.java:269)
05-13 23:31:46.250: W/ND(14594): at NE.a(FinalizableReferenceQueue.java:253)
I don't know if that could be related or not.
I can dump the whole LogCat in here if it will help.
Solution
You cannot share text to google document, but you can share a file (text file or other) So, just save your text into a file inside your application and share that file with the Intent :
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + your_file_path));
startActivity(Intent.createChooser(intent, ""));
Answered By - Etienne