├── AndroidManifest.xml
├── README.md
├── ant.properties
├── build.xml
├── local.properties
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-ldpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── layout
│ └── main.xml
└── values
│ └── strings.xml
└── src
└── com
└── example
└── TestWXMultiShare
├── MyActivity.java
└── ShareUtils.java
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##分享多张图片到微信朋友圈,并同时传递描述信息
2 |
3 | 微信官方的SDK目前版本是不支持多张图片分享的。但是Android系统下我们可以不实用微信的SDK搞定分享多张图片的目的。
4 |
5 | ###思路:
6 | 1. 微信默认情况下实现了Android系统的分享的Intent Action规则。因此我们可以反编译微信,找到多张图片分享界面对应的Activity,
7 | 此Activity正好实现了两个规则。因此我们可以直接调用此Activity将数据传递给它,达到分享的目的。
8 | 2. 自动传递描述信息,这就需要将其对应的来,找到如何通过Intent传递描述信息了。
9 |
10 | 详细解析:见博客[www.glanwang.com](www.glanwang.com)
11 |
--------------------------------------------------------------------------------
/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Applications/adt-bundle-mac-x86_64-20140702/sdk
11 |
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-L
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeffWangGithub/TestWXMultiShare/c8dd84a721bd251742f3f7355bddf6063274a18e/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeffWangGithub/TestWXMultiShare/c8dd84a721bd251742f3f7355bddf6063274a18e/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeffWangGithub/TestWXMultiShare/c8dd84a721bd251742f3f7355bddf6063274a18e/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeffWangGithub/TestWXMultiShare/c8dd84a721bd251742f3f7355bddf6063274a18e/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestWXMultiShare
4 |
5 |
--------------------------------------------------------------------------------
/src/com/example/TestWXMultiShare/MyActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.TestWXMultiShare;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Environment;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | import java.io.File;
10 | import java.io.FileFilter;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class MyActivity extends Activity implements View.OnClickListener{
15 |
16 | private File[] files;
17 | private List paths = new ArrayList();
18 |
19 | /**
20 | * Called when the activity is first created.
21 | */
22 | @Override
23 | public void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.main);
26 |
27 | // 遍历 SD 卡下 .png 文件通过微信分享,保证SD卡根目录下有.png的文件
28 | File root = Environment.getExternalStorageDirectory();
29 | files = root.listFiles(new FileFilter() {
30 | @Override
31 | public boolean accept(File pathname) {
32 | if (pathname.getName().endsWith(".JPEG"))
33 | return true;
34 | return false;
35 | }
36 | });
37 |
38 | for(File file :files){
39 | paths.add(file.getAbsolutePath());
40 | }
41 | }
42 |
43 | @Override
44 | public void onClick(View v) {
45 | switch (v.getId()){
46 | case R.id.share_btn1:
47 | if(paths == null || paths.size() == 0){
48 | Toast.makeText(this,"SD卡根目录下无.png格式照片",Toast.LENGTH_SHORT).show();
49 | }else{
50 | ShareUtils.share9PicsToWXCircle(this, "你好,成功的分享了多张照片到微信",paths);
51 | }
52 | break;
53 |
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/example/TestWXMultiShare/ShareUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.TestWXMultiShare;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageInfo;
7 | import android.net.Uri;
8 | import android.widget.Toast;
9 |
10 | import java.io.File;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | /**
15 | * @title:
16 | * @description:
17 | * @company: 美丽说(北京)网络科技有限公司
18 | * Created by Glan.Wang on 15/6/16.
19 | */
20 | public class ShareUtils {
21 | /**
22 | * 不实用微信的SDK分享图片到好友
23 | * @param context
24 | * @param path
25 | */
26 | public static void sharePicToFriendNoSDK(Context context, String path) {
27 | if(!isInstallWeChart(context)){
28 | Toast.makeText(context,"您没有安装微信",Toast.LENGTH_SHORT).show();
29 | return;
30 | }
31 | Intent intent = new Intent();
32 | ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
33 | intent.setComponent(comp);
34 | intent.setAction("android.intent.action.SEND");
35 | intent.setType("image/*");
36 | // intent.setFlags(0x3000001);
37 | File f = new File(path);
38 | if(f.exists()){
39 | intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
40 | } else {
41 | Toast.makeText(context,"文件不存在",Toast.LENGTH_SHORT).show();
42 | return;
43 | }
44 | context.startActivity(intent);
45 | }
46 |
47 |
48 | /**
49 | * 分享9图到朋友圈
50 | *
51 | * @param context
52 | * @param Kdescription 9图上边输入框中的文案
53 | * @param paths 本地图片的路径
54 | */
55 | public static void share9PicsToWXCircle(Context context, String Kdescription, List paths) {
56 | if (!isInstallWeChart(context)) {
57 | Toast.makeText(context,"您没有安装微信",Toast.LENGTH_SHORT).show();
58 | return;
59 | }
60 | Intent intent = new Intent();
61 | intent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI"));
62 | intent.setAction("android.intent.action.SEND_MULTIPLE");
63 |
64 | ArrayList imageList = new ArrayList();
65 | for (String picPath : paths) {
66 | File f = new File(picPath);
67 | if (f.exists()) {
68 | imageList.add(Uri.fromFile(f));
69 | }
70 | }
71 | if(imageList.size() == 0){
72 | Toast.makeText(context,"图片不存在",Toast.LENGTH_SHORT).show();
73 | return;
74 | }
75 | intent.setType("image/*");
76 | intent.putExtra(Intent.EXTRA_STREAM, imageList); //图片数据(支持本地图片的Uri形式)
77 | intent.putExtra("Kdescription", Kdescription); //微信分享页面,图片上边的描述
78 | context.startActivity(intent);
79 | }
80 |
81 | /**不实用微信sdk检查是否安装微信
82 | * @param context
83 | * @return
84 | */
85 | public static boolean isInstallWeChart(Context context){
86 | PackageInfo packageInfo = null;
87 | try {
88 | packageInfo = context.getPackageManager().getPackageInfo("com.tencent.mm", 0);
89 | } catch (Exception e) {
90 | packageInfo = null;
91 | e.printStackTrace();
92 | }
93 | if (packageInfo == null) {
94 | return false;
95 | } else {
96 | return true;
97 | }
98 | }
99 |
100 |
101 | }
102 |
--------------------------------------------------------------------------------