使用 Gmail 应用程序共享图像不起作用

发布于 2024-12-10 21:40:12 字数 1193 浏览 0 评论 0原文

我在与 Gmail 应用程序共享图像时遇到问题。 这是我的代码。

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);     
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,  getString(R.string.mail_subject)); 
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,  getString(R.string.mail_body)); 
    emailIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.facebook_share_text));


    //Download the image first
    String location=downloadImage(true);
    File root=android.os.Environment.getExternalStorageDirectory();
    Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);

    //Add attachment
    emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+root.getAbsolutePath()+"/"+location));

    emailIntent.setType("image/jpeg");
    startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));

默认电子邮件应用程序运行良好,Facebook Share 运行良好,Gmail 应用程序运行良好,但附件未发送,尽管显示为附件。

这是屏幕截图。 所有共享选项 电子邮件已发送,但没有附件,尽管此处显示附件 Facebook 分享非常完美

所以请帮忙。

I Have sharing image problem with the Gmail Application.
This is my code.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);     
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,  getString(R.string.mail_subject)); 
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,  getString(R.string.mail_body)); 
    emailIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.facebook_share_text));


    //Download the image first
    String location=downloadImage(true);
    File root=android.os.Environment.getExternalStorageDirectory();
    Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);

    //Add attachment
    emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+root.getAbsolutePath()+"/"+location));

    emailIntent.setType("image/jpeg");
    startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));

Default email app is Working great, Facebook Share is working great, Gmail App seams to work but the attachment is not send, although is displayed as attachment.

Here are the screen shots.
All share options
Email is send but without attachment, although the attachment is displayed here
Facebook share is perfect

So please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

池木 2024-12-17 21:40:12
String location=downloadImage(true);
File root=android.os.Environment.getExternalStorageDirectory();
Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);

//Add attachment
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+
root.getAbsolutePath()+"/"+location));
 // replace "Uri.parse" with Uri.fromFile(new File("file:///"+
root.getAbsolutePath()+"/"+location))
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));

这件事实际上对我有用。当我发送 Uri.parse 时,我也发生了同样的事情。您可以看到附件的大小将显示为 0 kb。但当我改变它时,它工作得很好。

String location=downloadImage(true);
File root=android.os.Environment.getExternalStorageDirectory();
Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location);

//Add attachment
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+
root.getAbsolutePath()+"/"+location));
 // replace "Uri.parse" with Uri.fromFile(new File("file:///"+
root.getAbsolutePath()+"/"+location))
emailIntent.setType("image/jpeg");
startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by)));

This thing actually worked for me. Same thing occurs to me, when I sent the Uri.parse. You can see that the size of the attachment will show 0 kb. But when I change it, it worked just fine.

烧了回忆取暖 2024-12-17 21:40:12

还可以在 facebook、whatsapp、gmail、蓝牙和消息上分享图像

            Uri imageUri = Uri.fromFile(file);
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_STREAM,imageUri);
            shareIntent.setType("image/*");
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(shareIntent,"Share with.."));

Share image working on facebook,whatsapp,gmail,bluetooth and messages also

            Uri imageUri = Uri.fromFile(file);
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_STREAM,imageUri);
            shareIntent.setType("image/*");
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(shareIntent,"Share with.."));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文