├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── key_strings.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── xyzlf │ │ │ │ └── share │ │ │ │ ├── wxapi │ │ │ │ └── WXEntryActivity.java │ │ │ │ ├── ShareCallBack.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xyzlf │ │ │ └── share │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xyzlf │ │ └── share │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── shareLibrary ├── .gitignore ├── libs │ ├── libammsdk-2.0.jar │ └── open_sdk_r5756_lite.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-xhdpi │ │ │ │ ├── share_qq.png │ │ │ │ ├── share_more.png │ │ │ │ ├── share_qzone.png │ │ │ │ ├── share_weibo.png │ │ │ │ ├── share_default.png │ │ │ │ ├── share_wechat.png │ │ │ │ ├── share_wxcircle.png │ │ │ │ └── weibosdk_dialog_bg.9.png │ │ │ ├── drawable │ │ │ │ ├── share_grid_item_pressed.xml │ │ │ │ ├── share_weibo_btn_disabled.xml │ │ │ │ ├── share_button_selector.xml │ │ │ │ ├── share_btn_bg.xml │ │ │ │ └── share_weibo_btn_selector.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── anim │ │ │ │ ├── activity_exit.xml │ │ │ │ └── activity_show.xml │ │ │ ├── values │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ └── layout │ │ │ │ ├── share_gridview_item.xml │ │ │ │ └── share_activity_dialog.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── xyzlf │ │ │ │ └── share │ │ │ │ └── library │ │ │ │ ├── interfaces │ │ │ │ ├── IShareBase.java │ │ │ │ ├── OnShareListener.java │ │ │ │ └── ShareConstant.java │ │ │ │ ├── channel │ │ │ │ ├── ShareBase.java │ │ │ │ ├── ShareByEmail.java │ │ │ │ ├── ShareBySystem.java │ │ │ │ ├── ShareBySms.java │ │ │ │ ├── ShareByQZone.java │ │ │ │ ├── ShareByQQ.java │ │ │ │ ├── ShareByWeibo2.java │ │ │ │ ├── ShareByWeixin.java │ │ │ │ └── ShareByWeibo.java │ │ │ │ ├── bean │ │ │ │ ├── ChannelEntity.java │ │ │ │ └── ShareEntity.java │ │ │ │ ├── util │ │ │ │ ├── ToastUtil.java │ │ │ │ ├── ChannelUtil.java │ │ │ │ ├── ManifestUtil.java │ │ │ │ └── ShareUtil.java │ │ │ │ ├── ShareBaseActivity.java │ │ │ │ ├── request │ │ │ │ ├── AbstractAsyncTask.java │ │ │ │ └── BitmapAsyncTask.java │ │ │ │ ├── AccessTokenKeeper.java │ │ │ │ ├── ShareHandlerActivity.java │ │ │ │ └── ShareDialogActivity.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── xyzlf │ │ └── com │ │ └── share │ │ └── library │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── share.png ├── 分享SDK使用说明文档.docx ├── 分享SDK使用说明文档.pdf ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── LICENSE ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /shareLibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':shareLibrary' 2 | -------------------------------------------------------------------------------- /share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/share.png -------------------------------------------------------------------------------- /分享SDK使用说明文档.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/分享SDK使用说明文档.docx -------------------------------------------------------------------------------- /分享SDK使用说明文档.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/分享SDK使用说明文档.pdf -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /shareLibrary/libs/libammsdk-2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/libs/libammsdk-2.0.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | /gradle.properties 9 | -------------------------------------------------------------------------------- /shareLibrary/libs/open_sdk_r5756_lite.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/libs/open_sdk_r5756_lite.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_qq.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_more.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_qzone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_qzone.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_weibo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_weibo.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_default.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_wechat.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/share_wxcircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/share_wxcircle.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable-xhdpi/weibosdk_dialog_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzlf/ShareSDK/HEAD/shareLibrary/src/main/res/drawable-xhdpi/weibosdk_dialog_bg.9.png -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable/share_grid_item_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable/share_weibo_btn_disabled.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 16 01:41:26 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable/share_button_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable/share_btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/xyzlf/share/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /shareLibrary/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xyzlf/share/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/interfaces/IShareBase.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.interfaces; 2 | 3 | import com.xyzlf.share.library.bean.ShareEntity; 4 | 5 | /** 6 | * Created by zhanglifeng 7 | */ 8 | public interface IShareBase { 9 | /** 10 | * @param data {@link ShareEntity} 11 | * @param listener {@link OnShareListener} 12 | */ 13 | void share(ShareEntity data, OnShareListener listener); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/key_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | your weixin key 10 | 11 | 12 | 222222 13 | 14 | 15 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/channel/ShareBase.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.channel; 2 | 3 | import android.content.Context; 4 | 5 | import com.xyzlf.share.library.interfaces.IShareBase; 6 | 7 | 8 | /** 9 | * Created by zhanglifeng 10 | */ 11 | public abstract class ShareBase implements IShareBase { 12 | 13 | Context context; 14 | 15 | public ShareBase(Context context) { 16 | this.context = context; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /shareLibrary/src/androidTest/java/com/xyzlf/com/share/library/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.com.share.library; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /shareLibrary/src/main/res/anim/activity_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/anim/activity_show.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ShareSDK 3 | 4 | 显示分享界面 5 | 6 | 调用QQ分享 7 | 调用微信分享 8 | 调用朋友圈分享 9 | 调用微博分享 10 | 调用QZone分享 11 | 12 | 分享大图 13 | 14 | 15 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/interfaces/OnShareListener.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.interfaces; 2 | 3 | /** 4 | * Created by zhanglifeng 5 | */ 6 | public interface OnShareListener { 7 | /** 8 | * @param channel {@link ShareConstant#SHARE_CHANNEL_ALL} 渠道 9 | * @param status {@link ShareConstant#SHARE_STATUS_COMPLETE} {@link ShareConstant#SHARE_STATUS_FAILED} 10 | * {@link ShareConstant#SHARE_STATUS_CANCEL} 11 | */ 12 | void onShare(int channel, int status); 13 | } 14 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/drawable/share_weibo_btn_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /shareLibrary/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\j-hurong-ncf\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\j-hurong-ncf\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -ignorewarnings 19 | -keep class com.tencent.mm.sdk.** { 20 | *; 21 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion '28.0.3' 6 | 7 | defaultConfig { 8 | applicationId "com.xyzlf.share" 9 | minSdkVersion 14 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | testImplementation 'junit:junit:4.12' 25 | implementation 'com.android.support:appcompat-v7:28.0.0' 26 | 27 | implementation ('com.xyzlf.share:sharesdk:0.0.10') { 28 | exclude group: 'com.android.support', module: 'appcompat-v7' 29 | } 30 | 31 | // compile project(':shareLibrary') 32 | } 33 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/bean/ChannelEntity.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.bean; 2 | 3 | /** 4 | * 渠道实体 5 | */ 6 | public class ChannelEntity { 7 | 8 | private int channel; 9 | private int icon; 10 | private String name; 11 | 12 | public ChannelEntity(int channel, int icon, String name) { 13 | this.channel = channel; 14 | this.icon = icon; 15 | this.name = name; 16 | } 17 | 18 | public int getIcon() { 19 | return icon; 20 | } 21 | 22 | public void setIcon(int icon) { 23 | this.icon = icon; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public int getchannel() { 35 | return channel; 36 | } 37 | 38 | public void setchannel(int channel) { 39 | this.channel = channel; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/layout/share_gridview_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 xyzlf 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/layout/share_activity_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 25 | 26 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /shareLibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ShareLibrary 3 | 4 | 分享到 5 | 6 | 分享內容不能为空 7 | 没有该分享渠道 8 | 9 | 10 | 分享失败,请先安装微信 11 | 12 | 13 | 分享成功 14 | 分享失败 15 | 分享取消 16 | 17 | 授权成功 18 | 授权失败 19 | 取消授权 20 | 分享失败,请先安装微博客户端 21 | 22 | 23 | 24 | 微信 25 | 朋友圈 26 | 微博 27 | QQ 28 | QQ空间 29 | 更多 30 | 31 | 32 | 33 | 图片保存失败 34 | SD卡未挂载 35 | 36 | 37 | -------------------------------------------------------------------------------- /shareLibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/util/ToastUtil.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.util; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.StringRes; 5 | import android.text.TextUtils; 6 | import android.widget.Toast; 7 | 8 | /** 9 | * Created by zhanglifeng 10 | */ 11 | public class ToastUtil { 12 | 13 | /** 14 | * 显示toast 15 | * @param context context 16 | * @param resId 资源id 17 | * @param isShort isShort 18 | */ 19 | public static void showToast(Context context, @StringRes int resId, boolean isShort) { 20 | if (null == context) { 21 | return; 22 | } 23 | String msg = null; 24 | try { 25 | msg = context.getString(resId); 26 | } catch (Exception e) { 27 | } 28 | if (TextUtils.isEmpty(msg)) { 29 | return; 30 | } 31 | showToast(context, msg, isShort); 32 | } 33 | 34 | /** 35 | * 显示toast 36 | * @param context context 37 | * @param msg 信息 38 | * @param isShort isShort 39 | */ 40 | public static void showToast(Context context, String msg, boolean isShort) { 41 | if (null == context) { 42 | return; 43 | } 44 | if (TextUtils.isEmpty(msg)) { 45 | return; 46 | } 47 | Toast.makeText(context, msg, isShort ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/ShareBaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v4.app.FragmentActivity; 7 | 8 | import com.xyzlf.share.library.interfaces.ShareConstant; 9 | 10 | 11 | public abstract class ShareBaseActivity extends FragmentActivity { 12 | 13 | protected int channel; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | if (null == getIntent()) { 19 | finish(); 20 | return; 21 | } 22 | initChannel(); 23 | } 24 | 25 | protected void initChannel() { 26 | try { 27 | //Fuzz问题处理 28 | channel = getIntent().getIntExtra(ShareConstant.EXTRA_SHARE_CHANNEL, ShareConstant.SHARE_CHANNEL_ALL); 29 | } catch (Exception e) {} 30 | } 31 | 32 | /** 33 | * @param channel {@link ShareConstant#SHARE_CHANNEL_ALL} 34 | * @param status {@link ShareConstant#SHARE_STATUS_CANCEL} 35 | */ 36 | public void finishWithResult(final int channel, final int status) { 37 | Intent intent = new Intent(); 38 | intent.putExtra(ShareConstant.EXTRA_SHARE_CHANNEL, channel); 39 | intent.putExtra(ShareConstant.EXTRA_SHARE_STATUS, status); 40 | setResult(Activity.RESULT_OK, intent); 41 | finish(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /shareLibrary/src/main/java/com/xyzlf/share/library/request/AbstractAsyncTask.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.library.request; 2 | 3 | import android.os.AsyncTask; 4 | 5 | /** 6 | * Created by zhanglifeng on 16/6/17 7 | */ 8 | public abstract class AbstractAsyncTask extends AsyncTask { 9 | private Exception exception; 10 | private T data; 11 | 12 | @Override 13 | protected T doInBackground(Void... voids) { 14 | try { 15 | data = doLoadData(); 16 | exception = null; 17 | } catch (Exception e) { 18 | data = null; 19 | exception = e; 20 | } 21 | return getData(); 22 | } 23 | 24 | protected abstract T doLoadData() throws Exception; 25 | 26 | public Exception getException() { 27 | return exception; 28 | } 29 | 30 | public T getData() { 31 | return data; 32 | } 33 | 34 | @Override 35 | protected void onPostExecute(T t) { 36 | try { 37 | if (exception == null) { 38 | onSuccess(t); 39 | } else { 40 | onException(exception); 41 | } 42 | } catch (Exception e) { 43 | e.printStackTrace(); 44 | } finally { 45 | onFinally(); 46 | } 47 | 48 | } 49 | 50 | public void onSuccess(T t) { 51 | } 52 | 53 | public void onFinally() { 54 | } 55 | 56 | public void onException(Exception exception) { 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyzlf/share/wxapi/WXEntryActivity.java: -------------------------------------------------------------------------------- 1 | package com.xyzlf.share.wxapi; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.tencent.mm.sdk.modelbase.BaseReq; 8 | import com.tencent.mm.sdk.modelbase.BaseResp; 9 | import com.tencent.mm.sdk.openapi.IWXAPI; 10 | import com.tencent.mm.sdk.openapi.IWXAPIEventHandler; 11 | import com.tencent.mm.sdk.openapi.WXAPIFactory; 12 | import com.xyzlf.share.MainActivity; 13 | import com.xyzlf.share.library.interfaces.ShareConstant; 14 | import com.xyzlf.share.library.util.ManifestUtil; 15 | 16 | /** 17 | * 这个类是微信回调的类 18 | */ 19 | public class WXEntryActivity extends Activity implements IWXAPIEventHandler { 20 | 21 | private IWXAPI api; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | api = WXAPIFactory.createWXAPI(this, ManifestUtil.getWeixinKey(this), false); 27 | api.handleIntent(getIntent(), this); 28 | } 29 | 30 | @Override 31 | protected void onNewIntent(Intent intent) { 32 | super.onNewIntent(intent); 33 | setIntent(intent); 34 | api.handleIntent(intent, this); 35 | } 36 | 37 | @Override 38 | public void onReq(BaseReq req) { 39 | 40 | } 41 | 42 | @Override 43 | public void onResp(BaseResp resp) { 44 | Intent intent = new Intent(); 45 | intent.setAction(ShareConstant.ACTION_WEIXIN_CALLBACK); 46 | intent.putExtra(ShareConstant.EXTRA_WEIXIN_RESULT, resp.errCode); 47 | sendBroadcast(intent); 48 | finish(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |