打开手机的能够分享的应用程序进行图片的分享
首先需要图片的绝对路径
String imgUrl = "/sdcard/DSYY/" + imgName;
File file = new File(imgUrl);
if (file.exists()) {
Intent sendMSGIntent = new Intent(Intent.ACTION_SEND);
sendMSGIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendMSGIntent.putExtra("compose_mode", false);
sendMSGIntent.putExtra("exit_on_sent", true);
// 添加附件
sendMSGIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(new File(imgUrl)));
// 设置文件类型 image/*为所有类型的图片
sendMSGIntent.setType("image/jpeg");
startActivity(sendMSGIntent);
} else {
//"图片不存在";
}