问题
I am using the following code to allow the user to share a bitmap,
try {
File save_dir = Environment.getExternalStorageDirectory();
FileOutputStream out = new FileOutputStream(save_dir
+ "/test.jpg");
final_bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///" + save_dir + "/test.jpg"));
startActivity(Intent.createChooser(share,
getString(R.string.share_dialog_title)));
} catch (Exception e) {
Toast.makeText(mainActivity, "Error in sharing.",
Toast.LENGTH_LONG).show();
}
the problem is, the if the device has no SD Card, the file will not be saved.
is there is any good way to save it to the internal storage, in somewhere other apps can access, since saving it in the applications data directory will not allow other applications to access it.
Regards
来源:https://stackoverflow.com/questions/10213296/share-a-file-without-saving-it-on-the-external-storage