gpt4 book ai didi

android - 当通过电子邮件从 Assets 发送图像时,邮件 View 显示 0kb 大小的图像?

转载 作者:行者123 更新时间:2023-11-29 13:59:11 24 4
gpt4 key购买 nike

我是一名新的 Android 开发人员,在我的应用程序中,我想通过电子邮件发送图像,该图像位于 Assets 文件夹中,邮件 View 显示图像附件大小为 0 kb,但图像名称已正确显示,这是我的代码是:

 try {
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/png");

String str = "image.png"
String imageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"file:///android_asset/Images/" + str;

File downloadedPic = new File(imageDirectoryPath);
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
} catch (Exception e) {
Toast.makeText(MyActivity.this, "No handler", Toast.LENGTH_LONG).show();
}

请给我任何建议...提前致谢...

最佳答案

MIME 类型有问题请更改 MIME 类型并重试。

picMessageIntent.setType("image/*");

picMessageIntent.setType("image/jpg");

关于android - 当通过电子邮件从 Assets 发送图像时,邮件 View 显示 0kb 大小的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10412434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com