图像无法识别
我有以下代码:
FileOutputStream out = null;
try {
out = new FileOutputStream("/sdcard/tmp/i.jpg");
b.compress(Bitmap.CompressFormat.JPEG, 90, out);
Toast.makeText(getApplicationContext(), "Succeded", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_LONG).show();
}
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/tmp/i.jpg"));
startActivity(Intent.createChooser(share, "Share image"));
当调用它时,一切正常。文件已保存并弹出选择器。但是一旦您进入您选择的活动,他们都会弹出一条消息,说我无法添加该图像。除了GMail,其他都很好用。那么我到底该怎么做才能解决这个问题呢?
I have the following code:
FileOutputStream out = null;
try {
out = new FileOutputStream("/sdcard/tmp/i.jpg");
b.compress(Bitmap.CompressFormat.JPEG, 90, out);
Toast.makeText(getApplicationContext(), "Succeded", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_LONG).show();
}
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/tmp/i.jpg"));
startActivity(Intent.createChooser(share, "Share image"));
When it is called it all works correctly. The file is saved and it pops up the chooser. but once you get to the activity you choose, they all pop up a message saying that I can't add that image. Except GMail, it works fine. So what on earth do I do to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有看到任何关闭
FileOutputStream
的代码。也许这就是问题的原因?保存图像后尝试调用out.close()
。更新:
还尝试使用完整图像路径,即尝试这样做:
I don't see any code to close the
FileOutputStream
. Maybe this is the issue reason? Try to callout.close()
after you save the image.UPDATE:
Also try to use full image path, i.e. try doing smth like this: