代码:
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long longParam) {
Bitmap b = BitmapFactory.decodeResource(getResources(),
mImageAdapter.getItem(position));
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(getContentResolver(),
b, "Photo", null);
Uri imageUri = Uri.parse(path);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(share, "Photo: Share Photo To...")
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
});
照片文件存储为原始资源文件夹中的Jpeg文件,由imageadapter检索。
路径似乎是空的,我无法弄清楚为什么会这样。到目前为止,我只在KitKat设备上遇到此问题。什么可能出错的想法以及我将如何修复它?提前致谢! :)