问题附加的内部文件到Gmail在我的Andr​​oid应用程序 [英] Problem Attaching internal file to GMail in my android app

查看:61
本文介绍了问题附加的内部文件到Gmail在我的Andr​​oid应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序将数据写入文本文件(SD卡和内部存储器)。 后来该应用程序的电子邮件的文本文件的人的名单。 我有麻烦的Gmail附加一个从内部应用程序文件区域拉一个文件。 原生的Andr​​oid邮件可以附加从内部或SD卡区中的文件没有问题。 Gmail会附加一个文件,如果它是从SD卡,但不会附加文件,如果其设在内部存储。

My app writes data to text files (on sd card and internal memory). Later the app emails the text files to a list of people. I am having trouble getting gmail to attach a file that is pulled from the internal application files area. 'Native Android mail' can attach a file from either internal or SD card area with no problem. Gmail will attach a file if it's from SD card, but won't attach a file if its located in internal storage.

//这发出了一个文件,从标清 - 适用于Android的邮件和Gmail

// this sends a file from SD - works for android mail and gmail

Intent jj=new Intent(android.content.Intent.ACTION_SEND);

String fileName = "file://" + Environment.getExternalStorageDirectory()+"/aFolder/externalfile.txt"           

jj.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileName));
jj.setType("text/plain");

Intent chooser = Intent.createChooser(jj , "Select Sender");
startActivity(chooser);

//这发出了一个内部​​文件的作品为Android的邮件,但没有使用Gmail发送附件

// this sends an internal file-works for android mail, but no attachment sent with gmail

Intent jj=new Intent(android.content.Intent.ACTION_SEND);

String fileName = "file://" + getFilesDir().toString() + "/internalfile.txt";

jj.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileName));
jj.setType("text/plain");

Intent chooser = Intent.createChooser(jj , "Select Sender");
startActivity(chooser);

有什么建议? 我是否需要给Gmail的特别许可,不知何故?
我的附件是所有文本文件 - 写的应用程序
内部文件是用openFileOutput创建(MYFILE,32769)

Any suggestions? Do I need to give Gmail special permission somehow?
My attachments are all text files - written by the app.
Internal files were created with openFileOutput(myFile,32769)

谢谢 约翰·D·

推荐答案

我找到了解决,这是为了使自己的内容提供商和URI传递给我的内容提供商作为附件的唯一途径。

the only way I found around this was to make my own content provider and pass in the uri to my content provider as the attachment.

这篇关于问题附加的内部文件到Gmail在我的Andr​​oid应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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