安卓手机分享图片

来源:互联网 发布:php curl 伪装浏览器 编辑:程序博客网 时间:2024/04/30 05:20

打开手机的能够分享的应用程序进行图片的分享

首先需要图片的绝对路径

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 {//"图片不存在";}



原创粉丝点击