├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── README_Detail.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-app-release-v0.2.0.apk ├── sample-app ├── .gitignore ├── actionshow ├── build.gradle ├── elbbbird-studio-debug.keystore ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── encore │ │ └── actionnow │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── encore │ │ │ └── actionnow │ │ │ ├── ShareActivity.java │ │ │ ├── ShareAllActivity.java │ │ │ ├── SocialActivity.java │ │ │ ├── SsoActivity.java │ │ │ ├── SsoAllActivity.java │ │ │ ├── app │ │ │ ├── BaseActivity.java │ │ │ └── SocialSDKApplication.java │ │ │ └── wxapi │ │ │ └── WXEntryActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_share.xml │ │ ├── activity_share_all.xml │ │ ├── activity_sso.xml │ │ ├── activity_sso_all.xml │ │ ├── content_main.xml │ │ ├── content_share.xml │ │ ├── content_share_all.xml │ │ ├── content_sso.xml │ │ └── content_sso_all.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── 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-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── encore │ └── actionnow │ └── ExampleUnitTest.java ├── settings.gradle └── socialsdk ├── .gitignore ├── build.gradle ├── libs ├── armeabi-v7a │ └── libweibosdkcore.so ├── libammsdk.jar ├── open_sdk_r5509_lite.jar ├── otto-1.3.8.jar └── weiboSDKCore_3.1.2.jar ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── elbbbird │ └── android │ └── socialsdk │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── elbbbird │ │ └── android │ │ └── socialsdk │ │ ├── SocialSDK.java │ │ ├── SocialUtils.java │ │ ├── WeChat.java │ │ ├── model │ │ ├── SocialInfo.java │ │ ├── SocialShareScene.java │ │ ├── SocialToken.java │ │ └── SocialUser.java │ │ ├── otto │ │ ├── BusProvider.java │ │ ├── MainThreadBus.java │ │ ├── SSOBusEvent.java │ │ └── ShareBusEvent.java │ │ ├── share │ │ ├── SocialShareActivity.java │ │ ├── SocialShareProxy.java │ │ ├── qq │ │ │ └── QQShareProxy.java │ │ ├── wechat │ │ │ ├── IWXShareCallback.java │ │ │ └── WeChatShareProxy.java │ │ └── weibo │ │ │ ├── AccessTokenKeeper.java │ │ │ └── WeiboShareProxy.java │ │ ├── sso │ │ ├── SocialInfoKeeper.java │ │ ├── SocialOauthActivity.java │ │ ├── SocialSSOProxy.java │ │ ├── SocialUserKeeper.java │ │ ├── qq │ │ │ └── QQSSOProxy.java │ │ ├── wechat │ │ │ ├── IWXCallback.java │ │ │ ├── WXCallbackActivity.java │ │ │ └── WeChatSSOProxy.java │ │ └── weibo │ │ │ ├── AbsOpenAPI.java │ │ │ ├── Geo.java │ │ │ ├── LogoutAPI.java │ │ │ ├── Status.java │ │ │ ├── StatusesAPI.java │ │ │ ├── User.java │ │ │ ├── UsersAPI.java │ │ │ ├── Visible.java │ │ │ └── WeiboSSOProxy.java │ │ └── view │ │ ├── OverlayImageView.java │ │ └── ShareButton.java └── res │ ├── anim │ ├── es_snack_in.xml │ └── es_snack_out.xml │ ├── drawable-xhdpi │ ├── es_icon_default.png │ ├── es_icon_more.png │ ├── es_icon_qq.png │ ├── es_icon_qzone.png │ ├── es_icon_wechat.png │ ├── es_icon_wechat_timeline.png │ └── es_icon_weibo.png │ ├── layout │ ├── es_activity_social_oauth.xml │ ├── es_activity_social_share.xml │ └── es_view_btn_share.xml │ └── values │ ├── es_attrs.xml │ ├── es_strings.xml │ └── es_styles.xml └── test └── java └── com └── elbbbird └── android └── socialsdk └── ExampleUnitTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | ### OSX template 10 | .DS_Store 11 | .AppleDouble 12 | .LSOverride 13 | 14 | # Icon must end with two \r 15 | Icon 16 | 17 | # Thumbnails 18 | ._* 19 | 20 | # Files that might appear in the root of a volume 21 | .DocumentRevisions-V100 22 | .fseventsd 23 | .Spotlight-V100 24 | .TemporaryItems 25 | .Trashes 26 | .VolumeIcon.icns 27 | 28 | # Directories potentially created on remote AFP share 29 | .AppleDB 30 | .AppleDesktop 31 | Network Trash Folder 32 | Temporary Items 33 | .apdisk 34 | ### Windows template 35 | # Windows image file caches 36 | Thumbs.db 37 | ehthumbs.db 38 | 39 | # Folder config file 40 | Desktop.ini 41 | 42 | # Recycle Bin used on file shares 43 | $RECYCLE.BIN/ 44 | 45 | # Windows Installer files 46 | *.cab 47 | *.msi 48 | *.msm 49 | *.msp 50 | 51 | # Windows shortcuts 52 | *.lnk 53 | ### JetBrains template 54 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 55 | 56 | ## Directory-based project format: 57 | .idea/ 58 | # if you remove the above rule, at least ignore the following: 59 | 60 | # User-specific stuff: 61 | # .idea/workspace.xml 62 | # .idea/tasks.xml 63 | # .idea/dictionaries 64 | 65 | # Sensitive or high-churn files: 66 | # .idea/dataSources.ids 67 | # .idea/dataSources.xml 68 | # .idea/sqlDataSources.xml 69 | # .idea/dynamic.xml 70 | # .idea/uiDesigner.xml 71 | 72 | # Gradle: 73 | # .idea/gradle.xml 74 | # .idea/libraries 75 | 76 | # Mongo Explorer plugin: 77 | # .idea/mongoSettings.xml 78 | 79 | ## File-based project format: 80 | *.ipr 81 | *.iws 82 | 83 | ## Plugin-specific files: 84 | 85 | # IntelliJ 86 | /out/ 87 | 88 | # mpeltonen/sbt-idea plugin 89 | .idea_modules/ 90 | 91 | # JIRA plugin 92 | atlassian-ide-plugin.xml 93 | 94 | # Crashlytics plugin (for Android Studio and IntelliJ) 95 | com_crashlytics_export_strings.xml 96 | crashlytics.properties 97 | crashlytics-build.properties 98 | ### Android template 99 | # Built application files 100 | #*.apk 101 | #*.ap_ 102 | 103 | # Files for the Dalvik VM 104 | *.dex 105 | 106 | # Java class files 107 | *.class 108 | 109 | # Generated files 110 | bin/ 111 | gen/ 112 | 113 | # Gradle files 114 | .gradle/ 115 | build/ 116 | 117 | # Local configuration file (sdk path, etc) 118 | local.properties 119 | 120 | # Proguard folder generated by Eclipse 121 | proguard/ 122 | 123 | # Log Files 124 | *.log 125 | 126 | # Android Studio Navigation editor temp files 127 | .navigation/ 128 | 129 | #Secret data 130 | /secret.properties -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - build-tools-23.0.1 6 | - android-23 7 | - extra-android-support 8 | - extra-google-m2repository 9 | - extra-android-m2repository 10 | licenses: 11 | - 'android-sdk-preview-license-52d11cd2' 12 | - 'android-sdk-license-.+' 13 | - 'google-gdk-license-.+' 14 | 15 | before_install: 16 | - chmod +x gradlew 17 | 18 | # cache between builds 19 | cache: 20 | directories: 21 | - $HOME/.m2 22 | - $HOME/.gradle 23 | 24 | script: 25 | - echo "Travis branch is $TRAVIS_BRANCH" 26 | - echo "Travis branch is in pull request $TRAVIS_PULL_REQUEST" 27 | - ./gradlew -Ptype="ci" build 28 | 29 | notifications: 30 | slack: elbbbird:oZtbiJ73VHFwjgrWqVQlfqy7 31 | email: false -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESSocialSDK 2 | 3 | [![Build Status](https://travis-ci.org/ElbbbirdStudio/ESSocialSDK.svg?branch=master)](https://travis-ci.org/ElbbbirdStudio/ESSocialSDK) 4 | [![version](https://img.shields.io/badge/version-0.2.0-brightgreen.svg)]() 5 | [![LICENSE](https://img.shields.io/badge/license-Apache%202-blue.svg)]() 6 | [![forks](https://img.shields.io/github/forks/ElbbbirdStudio/ESSocialSDK.svg)]() 7 | [![stars](https://img.shields.io/github/stars/ElbbbirdStudio/ESSocialSDK.svg)]() 8 | 9 | 10 | 社交登录授权,分享SDK 11 | 支持微信、微博、QQ登录授权 12 | 微信好友、微信朋友圈、微博、QQ好友、QQ空间分享以及系统默认分享 13 | 14 | ## 说明 15 | 每单个平台全部提供文档说明,内容较多,易混淆集成过程,所以,这里只提供一键登录,一键分享文档,使用默认UI。 16 | 如果需要单个平台的详细集成文档,参考[README_Detail.md](https://github.com/ElbbbirdStudio/ESSocialSDK/blob/master/README_Detail.md)。 17 | 默认UI效果截图: 18 | ![一键登录](https://raw.githubusercontent.com/ElbbbirdStudio/ESSocialSDK/master/screenshots/oauth_all.png) 19 | ![一键分享](https://raw.githubusercontent.com/ElbbbirdStudio/ESSocialSDK/master/screenshots/share_all.png) 20 | 21 | ## Gradle 22 | ```groovy 23 | compile 'com.elbbbird.android:socialsdk:0.2.0@aar' 24 | ``` 25 | 26 | ## Debug模式 27 | ```java 28 | SocialSDK.setDebugMode(true); //默认false 29 | ``` 30 | 31 | ## 项目配置 32 | - 配置微博后台回调地址 33 | SDK的默认回调地址为`http://www.sina.com`,需要在微博后台配置,否则会提示回调地址错误。 34 | 如果在`SocialSDK.init()`方法自定义了回调地址,需要在后台配置为相应地址。 35 | 36 | - WXEntryActivity 37 | 创建包名:`package_name.wxapi` 38 | 在该包名下创建类`WXEntryActivity`继承自`WXCallbackActivity` 39 | 40 | ```java 41 | package com.encore.actionnow.wxapi; 42 | public class WXEntryActivity extends WXCallbackActivity { 43 | 44 | } 45 | ``` 46 | 47 | - AndroidManifest.xml 48 | ```xml 49 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | ``` 69 | **以上配置中的`XXXXXXXXX`换成app_id.** 70 | 71 | 72 | ## 一键登录授权功能(微博,微信,QQ) 73 | 74 | ### 授权结果回调 75 | SDK使用了[Otto](http://square.github.io/otto/)作为事件库,用以组件通信。 76 | 在调用`SocialSDK.oauth()`接口`Activity`的`onCreate()`方法内添加 77 | ```java 78 | BusProvider.getInstance().register(this); 79 | ``` 80 | 在该`Activity`的`onDestroy()`方法添加 81 | ```java 82 | @Override 83 | protected void onDestroy() { 84 | BusProvider.getInstance().unregister(this); 85 | super.onDestroy(); 86 | } 87 | ``` 88 | 添加回调接口 89 | ```java 90 | @Subscribe 91 | public void onOauthResult(SSOBusEvent event) { 92 | switch (event.getType()) { 93 | case SSOBusEvent.TYPE_GET_TOKEN: 94 | SocialToken token = event.getToken(); 95 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString()); 96 | break; 97 | case SSOBusEvent.TYPE_GET_USER: 98 | SocialUser user = event.getUser(); 99 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString()); 100 | break; 101 | case SSOBusEvent.TYPE_FAILURE: 102 | Exception e = event.getException(); 103 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString()); 104 | break; 105 | case SSOBusEvent.TYPE_CANCEL: 106 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL"); 107 | break; 108 | } 109 | } 110 | ``` 111 | 112 | ### Oauth 113 | ```java 114 | SocialSDK.init("wechat_app_id", "wechat_app_secret", "weibo_app_id", "qq_app_id"); 115 | SocialSDK.oauth(context); 116 | ``` 117 | 118 | ### Revoke 119 | ```java 120 | SocialSDK.revoke(context); 121 | ``` 122 | 123 | ## 一键分享功能(微博,微信,朋友圈,QQ,QQ空间) 124 | 125 | ### SDK中`SocialShareScene`的定义 126 | ```java 127 | /** 128 | * 社会化分享数据类 129 | */ 130 | public class SocialShareScene implements Serializable { 131 | 132 | public static final int SHARE_TYPE_DEFAULT = 0; 133 | public static final int SHARE_TYPE_WEIBO = 1; 134 | public static final int SHARE_TYPE_WECHAT = 2; 135 | public static final int SHARE_TYPE_WECHAT_TIMELINE = 3; 136 | public static final int SHARE_TYPE_QQ = 4; 137 | public static final int SHARE_TYPE_QZONE = 5; 138 | 139 | /** 140 | * @param id 分享唯一标识符,可随意指定,会在分享结果ShareBusEvent中返回 141 | * @param appName 分享到QQ时需要指定,会在分享弹窗中显示该字段 142 | * @param type 分享类型 143 | * @param title 标题 144 | * @param desc 简短描述 145 | * @param thumbnail 缩略图网址 146 | * @param url WEB网址 147 | */ 148 | public SocialShareScene(int id, String appName, int type, String title, String desc, String thumbnail, String url) { 149 | this.id = id; 150 | this.appName = appName; 151 | this.type = type; 152 | this.title = title; 153 | this.desc = desc; 154 | this.thumbnail = thumbnail; 155 | this.url = url; 156 | } 157 | 158 | public SocialShareScene(int id, String appName, String title, String desc, String thumbnail, String url) { 159 | .... 160 | } 161 | ``` 162 | 163 | **一键分享需要调用第二个构造函数,type类型在SDK内部自动指定** 164 | 165 | ### 分享结果回调 166 | 167 | ```java 168 | @Subscribe 169 | public void onShareResult(ShareBusEvent event) { 170 | switch (event.getType()) { 171 | case ShareBusEvent.TYPE_SUCCESS: 172 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_SUCCESS " + event.getId()); 173 | break; 174 | case ShareBusEvent.TYPE_FAILURE: 175 | Exception e = event.getException(); 176 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_FAILURE " + e.toString()); 177 | break; 178 | case ShareBusEvent.TYPE_CANCEL: 179 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_CANCEL"); 180 | break; 181 | } 182 | } 183 | ``` 184 | 185 | ### ShareTo 186 | ```java 187 | SocialSDK.setDebugMode(true); 188 | SocialSDK.init("wechat_app_id", "weibo_app_id", "qq_app_id"); 189 | SocialSDK.shareTo(context, scene); 190 | ``` 191 | 192 | ## FAQ 193 | 194 | - 关于三个平台的账号 195 | 微博应用程序注册完成后,需要在后台配置测试账号,包名,签名信息,然后开始测试; 196 | 微信应用程序注册后,需要配置包名和签名,并提交审核通过,可以获得分享权限。SSO登录权限需要开发者认证。(保护费不到位,测试都不能做) 197 | QQ需要在后台配置测试账号才能SSO登录。 198 | 199 | - 如果只需要SDK中SSO授权和分享功能其中之一,`项目配置`是否有删减? 200 | 集成任何其中一个功能都需要做这些配置。 201 | 202 | - 是否需要配置权限? 203 | SDK已经在aar中添加三个平台需要的权限,以下 204 | ```xml 205 | 206 | 207 | 208 | 209 | 210 | ``` 211 | 212 | - ProGrard代码混淆 213 | 214 | ``` 215 | ##微信 216 | -keep class com.tencent.mm.sdk.** {*;} 217 | 218 | ##微博 219 | -keep public class com.sina.weibo.** {*;} 220 | -keep public class com.sina.sso.** {*;} 221 | 222 | ##otto 223 | -keepattributes *Annotation* 224 | -keepclassmembers class ** { 225 | @com.squareup.otto.Subscribe public *; 226 | @com.squareup.otto.Produce public *; 227 | } 228 | ``` 229 | 230 | ## LICENSE 231 | 232 | Copyright 2015 The ESSocialSDK authors 233 | 234 | Licensed under the Apache License, Version 2.0 (the "License"); 235 | you may not use this file except in compliance with the License. 236 | You may obtain a copy of the License at 237 | 238 | http://www.apache.org/licenses/LICENSE-2.0 239 | 240 | Unless required by applicable law or agreed to in writing, software 241 | distributed under the License is distributed on an "AS IS" BASIS, 242 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 243 | See the License for the specific language governing permissions and 244 | limitations under the License. 245 | -------------------------------------------------------------------------------- /README_Detail.md: -------------------------------------------------------------------------------- 1 | # ESSocialSDK [![Build Status](https://travis-ci.org/ElbbbirdStudio/ESSocialSDK.svg?branch=master)](https://travis-ci.org/ElbbbirdStudio/ESSocialSDK) 2 | 社交登录授权,分享SDK 3 | 支持微信、微博、QQ登录授权 4 | 微信好友、微信朋友圈、微博、QQ好友、QQ空间分享以及系统默认分享 5 | 6 | ## Gradle 7 | 8 | ```groovy 9 | compile 'com.elbbbird.android:socialsdk:0.2.0@aar' 10 | ``` 11 | 12 | ## Debug模式 13 | ```java 14 | SocialSDK.setDebugMode(true); //默认false 15 | ``` 16 | 17 | ## 社交平台SSO授权功能 18 | 19 | ### 授权结果回调 20 | SDK使用了[Otto](http://square.github.io/otto/)作为事件库,用以组件通信。 21 | 在调用`SocialSDK.oauth()`接口`Activity`的`onCreate()`方法内添加 22 | ```java 23 | BusProvider.getInstance().register(this); 24 | ``` 25 | 在该`Activity`的`onDestroy()`方法添加 26 | ```java 27 | @Override 28 | protected void onDestroy() { 29 | BusProvider.getInstance().unregister(this); 30 | super.onDestroy(); 31 | } 32 | ``` 33 | 添加回调接口 34 | ```java 35 | @Subscribe 36 | public void onOauthResult(BusEvent event) { 37 | switch (event.getType()) { 38 | case BusEvent.TYPE_GET_TOKEN: 39 | SocialToken token = event.getToken(); 40 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString()); 41 | break; 42 | case BusEvent.TYPE_GET_USER: 43 | SocialUser user = event.getUser(); 44 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString()); 45 | break; 46 | case BusEvent.TYPE_FAILURE: 47 | Exception e = event.getException(); 48 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString()); 49 | break; 50 | case BusEvent.TYPE_CANCEL: 51 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL"); 52 | break; 53 | } 54 | } 55 | ``` 56 | 57 | ### 微博授权 58 | - 配置微博后台回调地址 59 | SDK的默认回调地址为`http://www.sina.com`,需要在微博后台配置,否则会提示回调地址错误。 60 | 如果在`SocialSDK.initWeibo()`方法自定义了回调地址,需要在后台配置为相应地址。 61 | - oauth 62 | ```java 63 | SocialSDK.initWeibo("app_key"); 64 | SocialSDK.oauthWeibo(context); 65 | ``` 66 | - onActivityResult 67 | ```java 68 | SocialSDK.oauthWeiboCallback(context, requestCode, resultCode, data); 69 | ``` 70 | 71 | - revoke 72 | ```java 73 | SocialSDK.revokeWeibo(context); 74 | ``` 75 | 76 | ### 微信授权 77 | 78 | - WXEntryActivity 79 | 创建包名:`package_name.wxapi` 80 | 在该包名下创建类`WXEntryActivity`继承自`WXCallbackActivity` 81 | 82 | ```java 83 | package com.encore.actionnow.wxapi; 84 | public class WXEntryActivity extends WXCallbackActivity { 85 | 86 | } 87 | ``` 88 | 89 | - AndroidManifest.xml 90 | ```xml 91 | 97 | ``` 98 | 99 | - oauth 100 | ```java 101 | SocialSDK.initWeChat("app_id", "app_secret"); 102 | SocialSDK.oauthWeChat(context); 103 | ``` 104 | 105 | - revoke 106 | ```java 107 | SocialSDK.revokeWeChat(context); 108 | ``` 109 | 110 | ### QQ授权 111 | - AndroidManifest.xml 112 | ```xml 113 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | ``` 127 | **以上配置中的`XXXXXXXXX`换成app_id.** 128 | 129 | - oauth 130 | ```java 131 | SocialSDK.initQQ(app_id); 132 | SocialSDK.oauthQQ(context); 133 | ``` 134 | 135 | - onActivityResult 136 | ```java 137 | if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { 138 | SocialSDK.oauthQQCallback(requestCode, resultCode, data); 139 | } 140 | ``` 141 | 142 | - revoke 143 | ```java 144 | SocialSDK.revokeQQ(context); 145 | ``` 146 | 147 | ### SDK默认授权界面,展示全平台授权接口 148 | - 配置微博后台回调地址 149 | SDK的默认回调地址为`http://www.sina.com`,需要在微博后台配置,否则会提示回调地址错误。 150 | 如果在`SocialSDK.init()`方法自定义了回调地址,需要在后台配置为相应地址。 151 | 152 | - WXEntryActivity 153 | 创建包名:`package_name.wxapi` 154 | 在该包名下创建类`WXEntryActivity`继承自`WXCallbackActivity` 155 | 156 | ```java 157 | package com.encore.actionnow.wxapi; 158 | public class WXEntryActivity extends WXCallbackActivity { 159 | 160 | } 161 | ``` 162 | 163 | - AndroidManifest.xml 164 | ```xml 165 | 171 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | ``` 185 | **以上配置中的`XXXXXXXXX`换成app_id.** 186 | 187 | - oauth 188 | ```java 189 | SocialSDK.init("wechat_app_id", "wechat_app_secret", "weibo_app_id", "qq_app_id"); 190 | SocialSDK.oauth(context); 191 | ``` 192 | 193 | - revoke 194 | ```java 195 | SocialSDK.revoke(context); 196 | ``` 197 | 198 | ## 社交平台分享功能 199 | 200 | ### 分享结果回调 201 | 202 | ```java 203 | @Subscribe 204 | public void onShareResult(ShareBusEvent event) { 205 | switch (event.getType()) { 206 | case ShareBusEvent.TYPE_SUCCESS: 207 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_SUCCESS " + event.getId()); 208 | break; 209 | case ShareBusEvent.TYPE_FAILURE: 210 | Exception e = event.getException(); 211 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_FAILURE " + e.toString()); 212 | break; 213 | case ShareBusEvent.TYPE_CANCEL: 214 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_CANCEL"); 215 | break; 216 | } 217 | } 218 | ``` 219 | 220 | ## FAQ 221 | 222 | - 关于三个平台的账号 223 | 微博应用程序注册完成后,需要在后台配置测试账号,包名,签名信息,然后开始测试; 224 | 微信应用程序注册后,需要配置包名和签名,并提交审核通过,可以获得分享权限。SSO登录权限需要开发者认证。(保护费不到位,测试都不能做) 225 | QQ需要在后台配置测试账号才能SSO登录。 226 | 227 | - 是否需要配置权限? 228 | SDK已经在aar中添加三个平台需要的权限,以下 229 | ```xml 230 | 231 | 232 | 233 | 234 | 235 | ``` 236 | 237 | - ProGrard代码混淆 238 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Thu Nov 12 18:16:26 GMT+08:00 2015 16 | VERSION_NAME=0.2.0 17 | GROUP=com.elbbbird.android 18 | POM_PACKAGING=aar 19 | POM_NAME=ESSocialSDK 20 | POM_DESCRIPTION=ESSocialSDK 21 | 22 | POM_URL=https://github.com/ElbbbirdStudio/ESSocialSDK 23 | POM_SCM_URL=https://github.com/ElbbbirdStudio/ESSocialSDK 24 | POM_SCM_CONNECTION=scm:git:https://github.com/ElbbbirdStudio/ESSocialSDK.git 25 | POM_SCM_DEV_CONNECTION=scm:git:git@github.com:ElbbbirdStudio/ESSocialSDK.git 26 | 27 | POM_LICENSE_NAME=The Apache Software License, Version 2.0 28 | POM_LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 29 | POM_LICENSE_DIST=repo -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjie127/ESSocialSDK-master/bc27f42e3855109dbab52c8fb3513f6cd6cea62e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 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-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample-app-release-v0.2.0.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjie127/ESSocialSDK-master/bc27f42e3855109dbab52c8fb3513f6cd6cea62e/sample-app-release-v0.2.0.apk -------------------------------------------------------------------------------- /sample-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | ### OSX template 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk 27 | ### Windows template 28 | # Windows image file caches 29 | Thumbs.db 30 | ehthumbs.db 31 | 32 | # Folder config file 33 | Desktop.ini 34 | 35 | # Recycle Bin used on file shares 36 | $RECYCLE.BIN/ 37 | 38 | # Windows Installer files 39 | *.cab 40 | *.msi 41 | *.msm 42 | *.msp 43 | 44 | # Windows shortcuts 45 | *.lnk 46 | ### JetBrains template 47 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 48 | 49 | *.iml 50 | 51 | ## Directory-based project format: 52 | .idea/ 53 | # if you remove the above rule, at least ignore the following: 54 | 55 | # User-specific stuff: 56 | # .idea/workspace.xml 57 | # .idea/tasks.xml 58 | # .idea/dictionaries 59 | 60 | # Sensitive or high-churn files: 61 | # .idea/dataSources.ids 62 | # .idea/dataSources.xml 63 | # .idea/sqlDataSources.xml 64 | # .idea/dynamic.xml 65 | # .idea/uiDesigner.xml 66 | 67 | # Gradle: 68 | # .idea/gradle.xml 69 | # .idea/libraries 70 | 71 | # Mongo Explorer plugin: 72 | # .idea/mongoSettings.xml 73 | 74 | ## File-based project format: 75 | *.ipr 76 | *.iws 77 | 78 | ## Plugin-specific files: 79 | 80 | # IntelliJ 81 | /out/ 82 | 83 | # mpeltonen/sbt-idea plugin 84 | .idea_modules/ 85 | 86 | # JIRA plugin 87 | atlassian-ide-plugin.xml 88 | 89 | # Crashlytics plugin (for Android Studio and IntelliJ) 90 | com_crashlytics_export_strings.xml 91 | crashlytics.properties 92 | crashlytics-build.properties 93 | ### Android template 94 | # Built application files 95 | *.apk 96 | *.ap_ 97 | 98 | # Files for the Dalvik VM 99 | *.dex 100 | 101 | # Java class files 102 | *.class 103 | 104 | # Generated files 105 | bin/ 106 | gen/ 107 | 108 | # Gradle files 109 | .gradle/ 110 | build/ 111 | 112 | # Local configuration file (sdk path, etc) 113 | local.properties 114 | 115 | # Proguard folder generated by Eclipse 116 | proguard/ 117 | 118 | # Log Files 119 | *.log 120 | 121 | # Android Studio Navigation editor temp files 122 | .navigation/ 123 | 124 | -------------------------------------------------------------------------------- /sample-app/actionshow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjie127/ESSocialSDK-master/bc27f42e3855109dbab52c8fb3513f6cd6cea62e/sample-app/actionshow -------------------------------------------------------------------------------- /sample-app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | 4 | 5 | android { 6 | 7 | compileSdkVersion 23 8 | buildToolsVersion "23.0.1" 9 | defaultConfig { 10 | applicationId "com.encore.actionnow" 11 | minSdkVersion 15 12 | targetSdkVersion 23 13 | versionCode 1 14 | versionName VERSION_NAME 15 | } 16 | 17 | 18 | } 19 | 20 | dependencies { 21 | compile fileTree(include: ['*.jar'], dir: 'libs') 22 | testCompile 'junit:junit:4.12' 23 | compile 'com.android.support:appcompat-v7:23.1.1' 24 | compile 'com.android.support:design:23.1.1' 25 | compile 'com.jakewharton:butterknife:7.0.1' 26 | compile project(':socialsdk') 27 | } 28 | -------------------------------------------------------------------------------- /sample-app/elbbbird-studio-debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjie127/ESSocialSDK-master/bc27f42e3855109dbab52c8fb3513f6cd6cea62e/sample-app/elbbbird-studio-debug.keystore -------------------------------------------------------------------------------- /sample-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 D:\work\android-sdks/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 | 19 | -dontwarn org.apache.http.** 20 | 21 | ##微信 22 | -keep class com.tencent.mm.sdk.** {*;} 23 | 24 | ##微博 25 | -keep public class com.sina.weibo.** {*;} 26 | -keep public class com.sina.sso.** {*;} 27 | 28 | ##otto 29 | -keepattributes *Annotation* 30 | -keepclassmembers class ** { 31 | @com.squareup.otto.Subscribe public *; 32 | @com.squareup.otto.Produce public *; 33 | } 34 | 35 | #Butter Knife 36 | -keep class butterknife.** { *; } 37 | -dontwarn butterknife.internal.** 38 | -keep class **$$ViewBinder { *; } 39 | 40 | -keepclasseswithmembernames class * { 41 | @butterknife.* ; 42 | } 43 | 44 | -keepclasseswithmembernames class * { 45 | @butterknife.* ; 46 | } -------------------------------------------------------------------------------- /sample-app/src/androidTest/java/com/encore/actionnow/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.elbbbird.android.socialsdk.samples; 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 | } -------------------------------------------------------------------------------- /sample-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 54 | 55 | 56 | 57 | 58 | 59 | 62 | 63 | 68 | 71 | 72 | 77 | 80 | 81 | 86 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/ShareActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.widget.Button; 11 | 12 | import com.elbbbird.android.socialsdk.SocialSDK; 13 | import com.elbbbird.android.socialsdk.model.SocialShareScene; 14 | import com.elbbbird.android.socialsdk.otto.BusProvider; 15 | import com.elbbbird.android.socialsdk.otto.ShareBusEvent; 16 | import com.encore.actionnow.app.BaseActivity; 17 | import com.sina.weibo.sdk.api.share.BaseResponse; 18 | import com.sina.weibo.sdk.api.share.IWeiboHandler; 19 | import com.sina.weibo.sdk.constant.WBConstants; 20 | import com.squareup.otto.Subscribe; 21 | import com.tencent.connect.common.Constants; 22 | 23 | import butterknife.Bind; 24 | import butterknife.ButterKnife; 25 | import butterknife.OnClick; 26 | 27 | public class ShareActivity extends BaseActivity implements IWeiboHandler.Response { 28 | 29 | private static final String TAG = "ShareActivity"; 30 | 31 | private SocialShareScene scene = new SocialShareScene(0, "演技派", SocialShareScene.SHARE_TYPE_WECHAT, "Android 开源社会化登录 SDK,支持微信,微博, QQ", 32 | "像友盟, ShareSDK 等平台也提供类似的 SDK ,之所以造轮子是因为这些平台的 SDK 内部肯定会带有数据统计功能,不想给他们共享数据。", 33 | "http://cdn.v2ex.co/gravatar/becb0d5c59469a34a54156caef738e90?s=73&d=retro", "http://www.v2ex.com/t/238165"); 34 | 35 | @Bind(R.id.share_btn_share_qq) 36 | Button btnShareQQ; 37 | @Bind(R.id.share_btn_share_qzone) 38 | Button btnShareQZone; 39 | @Bind(R.id.share_btn_share_wechat) 40 | Button btnShareWeChat; 41 | @Bind(R.id.share_btn_share_wechat_timeline) 42 | Button btnShareWeChatTimeline; 43 | //disable,与SDK内部SocialShareActivity intent-filter冲突 44 | @Bind(R.id.share_btn_share_weibo) 45 | Button btnShareWeibo; 46 | 47 | @OnClick({R.id.share_btn_share_qq, R.id.share_btn_share_qzone, R.id.share_btn_share_wechat, R.id.share_btn_share_wechat_timeline, R.id.share_btn_share_weibo}) 48 | public void share(View view) { 49 | switch (view.getId()) { 50 | case R.id.share_btn_share_qq: 51 | SocialSDK.setDebugMode(true); 52 | SocialSDK.shareToQQ(ShareActivity.this, "1104664609", scene); 53 | break; 54 | case R.id.share_btn_share_qzone: 55 | SocialSDK.setDebugMode(true); 56 | SocialSDK.shareToQZone(ShareActivity.this, "1104664609", scene); 57 | break; 58 | case R.id.share_btn_share_wechat: 59 | SocialSDK.setDebugMode(true); 60 | SocialSDK.shareToWeChat(ShareActivity.this, "wx3ecc7ffe590fd845", scene); 61 | break; 62 | case R.id.share_btn_share_wechat_timeline: 63 | SocialSDK.setDebugMode(true); 64 | SocialSDK.shareToWeChatTimeline(ShareActivity.this, "wx3ecc7ffe590fd845", scene); 65 | break; 66 | case R.id.share_btn_share_weibo: 67 | SocialSDK.setDebugMode(true); 68 | SocialSDK.shareToWeibo(ShareActivity.this, "1633462674", scene); 69 | break; 70 | } 71 | } 72 | 73 | @Override 74 | protected void onCreate(Bundle savedInstanceState) { 75 | super.onCreate(savedInstanceState); 76 | setContentView(R.layout.activity_share); 77 | ButterKnife.bind(this); 78 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 79 | setSupportActionBar(toolbar); 80 | 81 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 82 | fab.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View view) { 85 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 86 | .setAction("Action", null).show(); 87 | } 88 | }); 89 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 90 | 91 | 92 | /*********************************************/ 93 | BusProvider.getInstance().register(this); 94 | /*********************************************/ 95 | } 96 | 97 | @Subscribe 98 | public void onShareResult(ShareBusEvent event) { 99 | switch (event.getType()) { 100 | case ShareBusEvent.TYPE_SUCCESS: 101 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_SUCCESS " + event.getId()); 102 | break; 103 | case ShareBusEvent.TYPE_FAILURE: 104 | Exception e = event.getException(); 105 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_FAILURE " + e.toString()); 106 | break; 107 | case ShareBusEvent.TYPE_CANCEL: 108 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_CANCEL"); 109 | break; 110 | } 111 | } 112 | 113 | @Override 114 | protected void onDestroy() { 115 | /*********************************************/ 116 | BusProvider.getInstance().unregister(this); 117 | /*********************************************/ 118 | super.onDestroy(); 119 | } 120 | 121 | @Override 122 | protected void onNewIntent(Intent intent) { 123 | super.onNewIntent(intent); 124 | 125 | SocialSDK.shareToWeiboCallback(intent, this); 126 | } 127 | 128 | @Override 129 | public void onResponse(BaseResponse baseResponse) { 130 | switch (baseResponse.errCode) { 131 | case WBConstants.ErrorCode.ERR_OK: 132 | BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_SUCCESS, scene.getType(), scene.getId())); 133 | break; 134 | case WBConstants.ErrorCode.ERR_CANCEL: 135 | BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_CANCEL, scene.getType())); 136 | break; 137 | case WBConstants.ErrorCode.ERR_FAIL: 138 | BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_FAILURE, scene.getType(), new Exception("WBConstants.ErrorCode.ERR_FAIL"))); 139 | break; 140 | } 141 | } 142 | 143 | @Override 144 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 145 | super.onActivityResult(requestCode, resultCode, data); 146 | 147 | if (requestCode == Constants.REQUEST_QZONE_SHARE || requestCode == Constants.REQUEST_QQ_SHARE) { 148 | SocialSDK.shareToQCallback(requestCode, resultCode, data); 149 | } 150 | 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/ShareAllActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.widget.Toolbar; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.Toast; 11 | 12 | import com.elbbbird.android.socialsdk.SocialSDK; 13 | import com.elbbbird.android.socialsdk.model.SocialShareScene; 14 | import com.elbbbird.android.socialsdk.otto.BusProvider; 15 | import com.elbbbird.android.socialsdk.otto.ShareBusEvent; 16 | import com.encore.actionnow.app.BaseActivity; 17 | import com.squareup.otto.Subscribe; 18 | 19 | import butterknife.Bind; 20 | import butterknife.ButterKnife; 21 | import butterknife.OnClick; 22 | 23 | public class ShareAllActivity extends BaseActivity { 24 | 25 | private static final String TAG = "ShareAllActivity"; 26 | 27 | private SocialShareScene scene = new SocialShareScene(0, "ESSocialSDK", "ESSocialSDK:Android社会化授权登录和分享工具", 28 | "社交登录授权,分享SDK。支持微信、微博、QQ登录授权;微信好友、微信朋友圈、微博、QQ好友、QQ空间分享以及系统默认分享", 29 | "http://cdn.v2ex.co/gravatar/becb0d5c59469a34a54156caef738e90?s=73&d=retro", "http://blog.elbbbird.com/2015/12/15/hello-essocialsdk/"); 30 | 31 | @Bind(R.id.share_all_btn_share_all) 32 | Button btnShareAll; 33 | 34 | @OnClick(R.id.share_all_btn_share_all) 35 | public void share(View view) { 36 | SocialSDK.setDebugMode(true); 37 | SocialSDK.init("wx3ecc7ffe590fd845", "1633462674", "1104664609"); 38 | SocialSDK.shareTo(ShareAllActivity.this, scene); 39 | } 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_share_all); 45 | ButterKnife.bind(this); 46 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 47 | setSupportActionBar(toolbar); 48 | 49 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 50 | fab.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View view) { 53 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 54 | .setAction("Action", null).show(); 55 | } 56 | }); 57 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 58 | 59 | /*********************************************/ 60 | BusProvider.getInstance().register(this); 61 | /*********************************************/ 62 | } 63 | 64 | @Subscribe 65 | public void onShareResult(ShareBusEvent event) { 66 | switch (event.getType()) { 67 | case ShareBusEvent.TYPE_SUCCESS: 68 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_SUCCESS " + event.getPlatform() + " " + event.getId()); 69 | Toast.makeText(ShareAllActivity.this, "ShareBusEvent.TYPE_SUCCESS", Toast.LENGTH_SHORT).show(); 70 | break; 71 | case ShareBusEvent.TYPE_FAILURE: 72 | Exception e = event.getException(); 73 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_FAILURE " + event.getPlatform() + " " + e.toString()); 74 | Toast.makeText(ShareAllActivity.this, "ShareBusEvent.TYPE_FAILURE", Toast.LENGTH_SHORT).show(); 75 | break; 76 | case ShareBusEvent.TYPE_CANCEL: 77 | Log.i(TAG, "onShareResult#ShareBusEvent.TYPE_CANCEL " + event.getPlatform() + " "); 78 | Toast.makeText(ShareAllActivity.this, "ShareBusEvent.TYPE_CANCEL", Toast.LENGTH_SHORT).show(); 79 | break; 80 | } 81 | } 82 | 83 | @Override 84 | protected void onDestroy() { 85 | /*********************************************/ 86 | BusProvider.getInstance().unregister(this); 87 | /*********************************************/ 88 | super.onDestroy(); 89 | 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/SocialActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.View; 9 | import android.widget.Button; 10 | 11 | import com.encore.actionnow.app.BaseActivity; 12 | 13 | import butterknife.Bind; 14 | import butterknife.ButterKnife; 15 | import butterknife.OnClick; 16 | 17 | public class SocialActivity extends BaseActivity { 18 | 19 | @Bind(R.id.main_btn_sso) 20 | Button btnSso; 21 | @Bind(R.id.main_btn_share) 22 | Button btnShare; 23 | @Bind(R.id.main_btn_share_all) 24 | Button btnShareAll; 25 | @Bind(R.id.main_btn_sso_all) 26 | Button btnSsoAll; 27 | 28 | @OnClick({R.id.main_btn_share, R.id.main_btn_sso, R.id.main_btn_share_all, R.id.main_btn_sso_all}) 29 | public void startActivity(View view) { 30 | 31 | Intent intent = new Intent(); 32 | switch (view.getId()) { 33 | case R.id.main_btn_sso: 34 | intent.setClass(SocialActivity.this, SsoActivity.class); 35 | break; 36 | 37 | case R.id.main_btn_share: 38 | intent.setClass(SocialActivity.this, ShareActivity.class); 39 | break; 40 | 41 | case R.id.main_btn_share_all: 42 | intent.setClass(SocialActivity.this, ShareAllActivity.class); 43 | break; 44 | 45 | case R.id.main_btn_sso_all: 46 | intent.setClass(SocialActivity.this, SsoAllActivity.class); 47 | break; 48 | } 49 | startActivity(intent); 50 | } 51 | 52 | @Override 53 | protected void onCreate(Bundle savedInstanceState) { 54 | super.onCreate(savedInstanceState); 55 | setContentView(R.layout.activity_main); 56 | ButterKnife.bind(this); 57 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 58 | setSupportActionBar(toolbar); 59 | 60 | 61 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 62 | fab.setOnClickListener(new View.OnClickListener() { 63 | @Override 64 | public void onClick(View view) { 65 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 66 | .setAction("Action", null).show(); 67 | } 68 | }); 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/SsoActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.widget.Button; 11 | 12 | import com.elbbbird.android.socialsdk.SocialSDK; 13 | import com.elbbbird.android.socialsdk.model.SocialToken; 14 | import com.elbbbird.android.socialsdk.model.SocialUser; 15 | import com.elbbbird.android.socialsdk.otto.BusProvider; 16 | import com.elbbbird.android.socialsdk.otto.SSOBusEvent; 17 | import com.encore.actionnow.app.BaseActivity; 18 | import com.squareup.otto.Subscribe; 19 | import com.tencent.connect.common.Constants; 20 | 21 | import butterknife.Bind; 22 | import butterknife.ButterKnife; 23 | import butterknife.OnClick; 24 | 25 | public class SsoActivity extends BaseActivity { 26 | 27 | private static final String TAG = "SsoActivity"; 28 | 29 | @Bind(R.id.sso_btn_login_qq) 30 | Button btnLoginQQ; 31 | @Bind(R.id.sso_btn_logout_qq) 32 | Button btnLogoutQQ; 33 | @Bind(R.id.sso_btn_login_wechat) 34 | Button btnLoginWeChat; 35 | @Bind(R.id.sso_btn_logout_wechat) 36 | Button btnLogoutWeChat; 37 | @Bind(R.id.sso_btn_login_weibo) 38 | Button btnLoginWeibo; 39 | @Bind(R.id.sso_btn_logout_weibo) 40 | Button btnLogoutWeibo; 41 | 42 | @OnClick({R.id.sso_btn_login_qq, R.id.sso_btn_login_wechat, R.id.sso_btn_login_weibo}) 43 | public void login(View view) { 44 | switch (view.getId()) { 45 | case R.id.sso_btn_login_weibo: 46 | SocialSDK.setDebugMode(true); 47 | SocialSDK.initWeibo("1633462674"); 48 | SocialSDK.oauthWeibo(SsoActivity.this); 49 | break; 50 | 51 | case R.id.sso_btn_login_wechat: 52 | SocialSDK.setDebugMode(true); 53 | SocialSDK.initWeChat("wx3ecc7ffe590fd845", "1b3f07fa99d82232d360c359f6504980"); 54 | SocialSDK.oauthWeChat(SsoActivity.this); 55 | break; 56 | 57 | case R.id.sso_btn_login_qq: 58 | SocialSDK.setDebugMode(true); 59 | SocialSDK.initQQ("1104664609"); 60 | SocialSDK.oauthQQ(SsoActivity.this); 61 | break; 62 | 63 | } 64 | } 65 | 66 | @OnClick({R.id.sso_btn_logout_qq, R.id.sso_btn_logout_wechat, R.id.sso_btn_logout_weibo}) 67 | public void logout(View view) { 68 | switch (view.getId()) { 69 | case R.id.sso_btn_logout_weibo: 70 | SocialSDK.revokeWeibo(SsoActivity.this); 71 | break; 72 | 73 | case R.id.sso_btn_logout_wechat: 74 | SocialSDK.revokeWeChat(SsoActivity.this); 75 | break; 76 | 77 | case R.id.sso_btn_logout_qq: 78 | SocialSDK.revokeQQ(SsoActivity.this); 79 | break; 80 | } 81 | } 82 | 83 | 84 | @Override 85 | protected void onCreate(Bundle savedInstanceState) { 86 | super.onCreate(savedInstanceState); 87 | setContentView(R.layout.activity_sso); 88 | ButterKnife.bind(this); 89 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 90 | setSupportActionBar(toolbar); 91 | 92 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 93 | fab.setOnClickListener(new View.OnClickListener() { 94 | @Override 95 | public void onClick(View view) { 96 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 97 | .setAction("Action", null).show(); 98 | } 99 | }); 100 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 101 | 102 | /**************************************************/ 103 | BusProvider.getInstance().register(this); 104 | /**************************************************/ 105 | } 106 | 107 | @Subscribe 108 | public void onOauthResult(SSOBusEvent event) { 109 | switch (event.getType()) { 110 | case SSOBusEvent.TYPE_GET_TOKEN: 111 | SocialToken token = event.getToken(); 112 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString()); 113 | break; 114 | case SSOBusEvent.TYPE_GET_USER: 115 | SocialUser user = event.getUser(); 116 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString()); 117 | break; 118 | case SSOBusEvent.TYPE_FAILURE: 119 | Exception e = event.getException(); 120 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString()); 121 | break; 122 | case SSOBusEvent.TYPE_CANCEL: 123 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL"); 124 | break; 125 | } 126 | } 127 | 128 | @Override 129 | protected void onDestroy() { 130 | /*********************************************/ 131 | BusProvider.getInstance().unregister(this); 132 | /*********************************************/ 133 | super.onDestroy(); 134 | } 135 | 136 | @Override 137 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 138 | super.onActivityResult(requestCode, resultCode, data); 139 | SocialSDK.oauthWeiboCallback(SsoActivity.this, requestCode, resultCode, data); 140 | if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { 141 | SocialSDK.oauthQQCallback(requestCode, resultCode, data); 142 | } 143 | 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/SsoAllActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.widget.Toolbar; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.Toast; 11 | 12 | import com.elbbbird.android.socialsdk.SocialSDK; 13 | import com.elbbbird.android.socialsdk.model.SocialToken; 14 | import com.elbbbird.android.socialsdk.model.SocialUser; 15 | import com.elbbbird.android.socialsdk.otto.BusProvider; 16 | import com.elbbbird.android.socialsdk.otto.SSOBusEvent; 17 | import com.encore.actionnow.app.BaseActivity; 18 | import com.squareup.otto.Subscribe; 19 | 20 | import butterknife.Bind; 21 | import butterknife.ButterKnife; 22 | import butterknife.OnClick; 23 | 24 | public class SsoAllActivity extends BaseActivity { 25 | 26 | private static final String TAG = "SsoAllActivity"; 27 | 28 | @Bind(R.id.sso_all_btn_login_all) 29 | Button btnLoginAll; 30 | @Bind(R.id.sso_all_btn_logout_all) 31 | Button btnLogoutAll; 32 | 33 | @OnClick(R.id.sso_all_btn_login_all) 34 | public void login(View view) { 35 | SocialSDK.setDebugMode(true); 36 | SocialSDK.init("wx3ecc7ffe590fd845", "1b3f07fa99d82232d360c359f6504980", "1633462674", "1104664609"); 37 | SocialSDK.oauth(SsoAllActivity.this); 38 | } 39 | 40 | @OnClick(R.id.sso_all_btn_logout_all) 41 | public void logout(View view) { 42 | SocialSDK.revoke(SsoAllActivity.this); 43 | } 44 | 45 | @Override 46 | protected void onCreate(Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(R.layout.activity_sso_all); 49 | ButterKnife.bind(this); 50 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 51 | setSupportActionBar(toolbar); 52 | 53 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 54 | fab.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View view) { 57 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 58 | .setAction("Action", null).show(); 59 | } 60 | }); 61 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 62 | 63 | /**************************************************/ 64 | BusProvider.getInstance().register(this); 65 | /**************************************************/ 66 | } 67 | 68 | @Subscribe 69 | public void onOauthResult(SSOBusEvent event) { 70 | switch (event.getType()) { 71 | case SSOBusEvent.TYPE_GET_TOKEN: 72 | SocialToken token = event.getToken(); 73 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString()); 74 | break; 75 | case SSOBusEvent.TYPE_GET_USER: 76 | SocialUser user = event.getUser(); 77 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString()); 78 | Toast.makeText(SsoAllActivity.this, "ShareBusEvent.TYPE_GET_USER \n\r" + user.toString(), Toast.LENGTH_SHORT).show(); 79 | break; 80 | case SSOBusEvent.TYPE_FAILURE: 81 | Exception e = event.getException(); 82 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString()); 83 | break; 84 | case SSOBusEvent.TYPE_CANCEL: 85 | Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL"); 86 | break; 87 | } 88 | } 89 | 90 | 91 | @Override 92 | protected void onDestroy() { 93 | /*********************************************/ 94 | BusProvider.getInstance().unregister(this); 95 | /*********************************************/ 96 | super.onDestroy(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/app/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow.app; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | 5 | /** 6 | * Created by zhanghailong-ms on 2015/12/9. 7 | */ 8 | public class BaseActivity extends AppCompatActivity { 9 | } 10 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/app/SocialSDKApplication.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow.app; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by zhanghailong-ms on 2015/11/13. 7 | *

8 | * 自定义Application 9 | */ 10 | public class SocialSDKApplication extends Application { 11 | 12 | @Override 13 | public void onCreate() { 14 | 15 | initBugHD(); 16 | super.onCreate(); 17 | } 18 | 19 | /** 20 | * 初始化BugHD,实时监控APP的崩溃 21 | */ 22 | private void initBugHD() { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/encore/actionnow/wxapi/WXEntryActivity.java: -------------------------------------------------------------------------------- 1 | package com.encore.actionnow.wxapi; 2 | 3 | 4 | import com.elbbbird.android.socialsdk.sso.wechat.WXCallbackActivity; 5 | 6 | public class WXEntryActivity extends WXCallbackActivity { 7 | 8 | } -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_share.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_share_all.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_sso.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_sso_all.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 |