Reputation:
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?
Upvotes: 0
Views: 105
Reputation: 28418
I don't see any code to close the FileOutputStream
. Maybe this is the issue reason? Try to call out.close()
after you save the image.
UPDATE:
Also try to use full image path, i.e. try doing smth like this:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/tmp/i.jpg"));
Upvotes: 1