卸载附件未标记为android系统中下载错误 [英] Unloaded attachment isn't marked for download error in android

查看:119
本文介绍了卸载附件未标记为android系统中下载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写手机通讯录到一个文件,并通过电子邮件的意图行动将其导出。当我将文件写入SD card.But当我写文件到模拟器我得到的邮件,而附件的手机内存出口工作正常。我的日志显示未装附件不标记为下载。

I am writing phone contacts to a file and exporting it through Email intent Action. Export works fine when i write the file to SD card.But when i write the file to phone memory of the emulator i get the mail without attachment. My Log displays "Unloaded attachment isn't marked for download".

下面是我的code

        file = new File(ctx.getFilesDir().getAbsolutePath(),"file.txt");

        if (file.exists()) {
            file.delete();

        }
        writer = new BufferedWriter(new FileWriter(file));
        for (int i = 0; i < names.size(); i++) {
            writer.write(names.get(i) + "," + phnno.get(i) + "\r\n");
        }

        writer.flush();
        writer.close();

这是我的电子邮件意图

                                Uri u1 = null;
                                u1 = Uri.fromFile(file);
                                System.out.println("u1 of URI"+u1); //u1 in logcat is "file:///data/data/com.android.contactxport/files/file.txt"


                                Intent sendIntent = new Intent(
                                        Intent.ACTION_SEND);
                                sendIntent.putExtra(Intent.EXTRA_SUBJECT,
                                        "Mail from ContactXPort App");
                                sendIntent
                                        .putExtra(Intent.EXTRA_STREAM, u1);
                                sendIntent.setType("text/html");
                                startActivity(sendIntent);

编辑:关于卸载附件的documnetation说:

/**
 * Check whether the message with a given id has unloaded attachments.  If the message is
 * a forwarded message, we look instead at the messages's source for the attachments.  If the
 * message or forward source can't be found, we return false
 * @param context the caller's context
 * @param messageId the id of the message
 * @return whether or not the message has unloaded attachments
 */
public static boolean hasUnloadedAttachments(Context context, long messageId) {
    Message msg = Message.restoreMessageWithId(context, messageId);
    if (msg == null) return false;
    Attachment[] atts = Attachment.restoreAttachmentsWithMessageId(context, messageId);
    for (Attachment att: atts) {
        if (!attachmentExists(context, att)) {
            // If the attachment doesn't exist and isn't marked for download, we're in trouble
            // since the outbound message will be stuck indefinitely in the Outbox.  Instead,
            // we'll just delete the attachment and continue; this is far better than the
            // alternative.  In theory, this situation shouldn't be possible.
            if ((att.mFlags & (Attachment.FLAG_DOWNLOAD_FORWARD |
                    Attachment.FLAG_DOWNLOAD_USER_REQUEST)) == 0) {
                Log.d(Logging.LOG_TAG, "Unloaded attachment isn't marked for download: " +
                        att.mFileName + ", #" + att.mId);
                Attachment.delete(context, Attachment.CONTENT_URI, att.mId);
            } else if (att.mContentUri != null) {
                // In this case, the attachment file is gone from the cache; let's clear the
                // contentUri; this should be a very unusual case
                ContentValues cv = new ContentValues();
                cv.putNull(AttachmentColumns.CONTENT_URI);
                Attachment.update(context, Attachment.CONTENT_URI, att.mId, cv);
            }
            return true;
        }
    }
    return false;
}

我的理解是路径问题here.But路径是菲英岛,当我在日志打印了。

Which i understand is the path is the issue here.But the path is fyn when i printed it in log.

任何帮助很多AP preciated。
先谢谢了。

Any help is much appreciated. Thanks in advance.

推荐答案

这是什么文件说,有关内部存储:

This is what the documentation says about internal storage:

默认情况下,保存到内部存储文件是私有的应用程序和其他应用程序无法访问它们(也可以在用户)。

所以,我现在想用我的应用程序安装文件的原生Android电子邮件应用程序的功能。

So i am now trying to use the native android Email App feature of attaching file in my Application.

或者我可以使用其他后端开发技术附加文件,我要导出的内容。

or i can use other back-end development technique to attach file with the contents i want to export.

这篇关于卸载附件未标记为android系统中下载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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