用ACTION_SEND 发送图片如果 i.setType("image/jpeg");
i.putExtra(Intent.EXTRA_STREAM, Img.getThumbFileUri());
MyMv.getContext().startActivity(Intent.createChooser(i,"Send Image To:"));
一定会提示错误解决办法 必须将这个图片找个地方保存,然后用uri的形式读取出来,这里有两种办法
第一种就是将图片插入到gally中:
File imageFile = new File(Constants.SYSTEM_DYNOMASTER_DIR,filename);
FileOutputStream fout = new FileOutputStream(imageFile);
blankBitmap.compress(CompressFormat.JPEG, 100, fout);
fout.flush();
fout.close();
String url = Media.insertImage(context.getContentResolver(), imageFile.getAbsolutePath(), imageFile.getName(), imageFile.getName());
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(Intent.EXTRA_TEXT, body);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
shareIntent.setType("image/jpeg");
context.startActivity(shareIntent);
第二种保存在其他地方:
FileOutputStream Os = getAppContext().openFileOutput("Img" + _PicId + ".jpg", Context.MODE_WORLD_READABLE);
Bm.compress(Bitmap.CompressFormat.JPEG, 100, Os);
Os.close();
然后
File F = getAppContext().getFileStreamPath("Img" + _PicId + ".jpg");
Uri U = Uri.fromFile(F);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/jpg");
i.putExtra(Intent.EXTRA_STREAM, U);
getContext().startActivity(Intent.createChooser(i,"Send Image To:"));<!-- / message --><!-- old edit msg spot --><!-- old edit msg spot -->