我是一名新的Android开发人员,在我的应用程序中,我希望通过电子邮件发送图像,该图像位于Assets文件夹中,邮件程序视图显示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();
}
请求给我任何建议...... Thanx in Advance ...
答案 0 :(得分:0)
MIME类型存在一些问题,请更改MIME类型,然后重试。
picMessageIntent.setType("image/*");
或
picMessageIntent.setType("image/jpg");