我有ImageView,我想分享它的图像.
以下是我的代码,
btshare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View content = findViewById(R.id.full_image_view);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File root = Environment.getExternalStorageDirectory();
File cachePath = new File(root.getAbsolutePath() + "/DCIM/Camera/image.jpg");
try
{
root.createNewFile();
FileOutputStream ostream = new FileOutputStream(root);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
Intent shareIntent = new Intent(Intent.ACTION_SEND);
Uri phototUri = Uri.parse("/DCIM/Camera/image.jpg");
shareIntent.setData(phototUri);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, phototUri);
startActivity(Intent.createChooser(shareIntent, "Share Via"));
}
});
Run Code Online (Sandbox Code Playgroud)
当我按下按钮我得到这些错误?
01-13 06:00:19.282: W/System.err(6199): java.io.FileNotFoundException: /storage/emulated/0: open failed: EISDIR (Is a directory) …Run Code Online (Sandbox Code Playgroud)