Android的意图分享text / plain的数据,谷歌驱动器 [英] Android intent to share text/plain data to Google Drive

查看:229
本文介绍了Android的意图分享text / plain的数据,谷歌驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的记事本程序实现了ACTION_SEND份额意图分享笔记。

I've created a simple notepad app which implements the ACTION_SEND share intent to share notes.

我的数据具有文本/纯和谷歌驱动器(原谷歌文档)是作为我的设备上的选择,当我选择谷歌驱动器出现错误此项目不能上传为谷歌文档的MIME类型通过敬酒的消息。

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);

应用程序,如邮件,邮件,微博和Word preSS似乎都处理这个意图良好,份额至少EXTRA_TEXT内容。

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?

我是新来的Andr​​oid所以请原谅我的愚蠢,如果这原来是一个愚蠢的问题。 我正在开发以最小的SDK版本15,有没有什么帮助的。

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:

在LogCat中,我再次发现该错误消息:

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.

我可以放弃整个LogCat中在这里如果它将帮助。

I can dump the whole LogCat in here if it will help.

推荐答案

您不能共享文本,以谷歌文档,但你可以共享文件(文本文件或其他) 所以,你的文字只是保存到你的应用程序中的一个文件,并与意向共享文件:

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, ""));

这篇关于Android的意图分享text / plain的数据,谷歌驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆