Android-分享多图到微信好友
/** * 微信分享(多图片) */ private static void shareWeChatByImgList(String kDescription, List<File> img_path_list, ShareChannel shareChannel) { try { if (img_path_list == null || img_path_list.size() <= 0) { ToastUtils.showShort("分享失败"); LogUtils.dTag(TAG, "分享:分享的图片地址列表为null"); return; } // 构建文件 Uri 列表 ArrayList<Uri> paths = new ArrayList<>(); for (File file : img_path_list) { paths.add(Uri.fromFile(file)); } Intent intent = new Intent(Intent.ACTION_SEND); intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.setType("image/*"); ComponentName comp = null; switch (shareChannel) { case WXSceneTimeline: comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI"); break; default: comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI"); break; } intent.setComponent(comp); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, paths); ActivityUtils.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
新人学习中,也不太会总结,有做的不对的地方希望各位大神指出,谢谢。