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();
        }


    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM