0

我有一个名为 card1.jpg 的文件存储在 assets 文件夹中。当我的程序运行时,它会在电子邮件中显示一个纸夹,当我按下发送时,似乎一切正常。但是....没有任何附件被发送。

代码:case R.id.butEmail: Intent msg = new Intent(Intent.ACTION_SEND); msg.setType("文本/纯文本"); msg.putExtra(Intent.EXTRA_EMAIL, new String[] {"tedpottel@gmail.com"}); msg.putExtra(Intent.EXTRA_TEXT, "附加图片"); msg.putExtra(Intent.EXTRA_SUBJECT, "Just Feet");

            String rawFolderPath = "file://android_assets//card1.jpg";

            Uri emailUri = Uri.parse(rawFolderPath );
            msg.putExtra(Intent.EXTRA_STREAM, emailUri);
            msg.setType("application/jpg");
            startActivity(Intent.createChooser(msg, "Emailinng..."));

            break;
4

1 回答 1

0

Two points:

  • You are using wrong path to the asset folder. There should be three slashes. And you need not to use double slashes for the folder hierarchy. The correct path to the asset folder is:

    file:///android_assets/folder1/folder2/image.png"

  • Your asset folder is local to your application(your process) so, applications outside your process(application) cannot access your asset folder.

于 2012-09-09T17:49:28.000 回答