Skip to content

Commit

Permalink
更新sdk v1.0 打jar包
Browse files Browse the repository at this point in the history
更新sample代码
更新readme
  • Loading branch information
tangsiyuan committed Aug 19, 2016
1 parent f81eb5d commit 2767436
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 42 deletions.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
|版本号|更新内容|
|---|---|
|1.0|集成微信授权登录,5种分享媒介,微信会话分享,微信朋友圈分享|
|1.1|集成QQ授权登录,QQ分享,QQ空间分享|

## 1 目录介绍

Expand All @@ -22,13 +23,16 @@
- social_sdk/ sdk的开发源码module 开发完成后用gradle中makejar打成jar包
- social_sdk.jar sdk的jar包 直接使用.搭配所需的平台sdk包.
- weixin_sdk_v3.1.1.jar 微信sdk
- qq_mta-sdk-1.6.2.jar qq sdk
- qq_sdk_v3.1.0.jar qq sdk
- SampleCode/ 一个示例代码(非可运行项目)

## 2 功能介绍

### 2.1 授权登录

1. 微信授权登录
2. QQ授权登录

### 2.2 分享

Expand All @@ -44,6 +48,8 @@

1. 微信会话分享
1. 微信朋友圈分享
1. QQ分享
1. QQ空间分享

## 3 开发说明

Expand Down Expand Up @@ -78,7 +84,7 @@ PlatformConfig.setWeixin(WX_APPID, WX_APPSECRET);
初始化api:

```java
SocialApi mSocialApi = SocialApi.get(this);
SocialApi mSocialApi = SocialApi.get(getApplicationContext());
```

登录授权:
Expand Down Expand Up @@ -231,6 +237,54 @@ PlatformType:

使用微信登录分享需要签名打包,并且签名和包名要和微信平台填入的信息一致。


### 4.2 QQ

#### 4.2.1 集成sdk

将目录中的qq_mta-sdk-1.6.2.jar和qq_sdk_v3.1.0.jar放入项目.

#### 4.2.2 配置

AndroidManifest中添加:

```java
<!--qq-->
<activity
android:name="com.tencent.tauth.AuthActivity"
android:noHistory="true"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent你的appid" />
</intent-filter>
</activity>
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
```

#### 4.2.3 常量定义

设置配置信息:

```java
PlatformConfig.setQQ(QQ_APPID);
```

PlatformType:

微信:PlatformType.QQ(可用于登录和QQ分享)

朋友圈:PlatformType.QZONE(用于qq控件分享)

#### 4.2.4 注意

使用QQ登录需要签名打包,并且签名和包名要和QQ开放平台填入的信息一致。

## 欢迎关注我的公众号

![我的公众号](https://github.com/tsy12321/PayAndroid/blob/master/wxmp_avatar.jpg)
96 changes: 55 additions & 41 deletions SampleCode/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class MainActivity extends AppCompatActivity {

private static final String WX_APPID = ""; //申请的wx appid
private static final String WX_APPSECRET = ""; //申请的wx appsecret
private static final String QQ_APPID = ""; //申请的qq appid

private SocialApi mSocialApi;

Expand All @@ -19,17 +20,39 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

PlatformConfig.setWeixin(WX_APPID, WX_APPSECRET);
mSocialApi = SocialApi.get(this);
PlatformConfig.setQQ(QQ_APPID);
mSocialApi = SocialApi.get(getApplicationContext());
}

/**
* 微信登录
*/
@OnClick(R.id.btnWXLogin)
public void onWXLogin() {
PlatformConfig.setWeixin(WX_APPID, WX_APPSECRET);
SocialApi api = SocialApi.get(this);
api.doOauthVerify(this, PlatformType.WEIXIN, new AuthListener() {
mSocialApi.doOauthVerify(this, PlatformType.WEIXIN, new AuthListener() {
@Override
public void onComplete(PlatformType platform_type, Map<String, String> map) {
Log.i("tsy", "login onComplete:" + map);
}

@Override
public void onError(PlatformType platform_type, String err_msg) {
Log.i("tsy", "login onError:" + err_msg);
}

@Override
public void onCancel(PlatformType platform_type) {
Log.i("tsy", "login onCancel");
}
});
}

/**
* qq登录
*/
@OnClick(R.id.btnQQLogin)
public void onQQLogin() {
mSocialApi.doOauthVerify(this, PlatformType.QQ, new AuthListener() {
@Override
public void onComplete(PlatformType platform_type, Map<String, String> map) {
Log.i("tsy", "login onComplete:" + map);
Expand Down Expand Up @@ -93,55 +116,46 @@ public void onShare() {
//分享渠道
switch (radioGSharePlatform.getCheckedRadioButtonId()) {
case R.id.radioShareWX:
doShareWX(shareMedia);
mSocialApi.doShare(this, PlatformType.WEIXIN, shareMedia, new MyShareListener());
break;

case R.id.radioShareWXCircle:
doShareWXCircle(shareMedia);
mSocialApi.doShare(this, PlatformType.WEIXIN_CIRCLE, shareMedia, new MyShareListener());
break;

case R.id.radioShareQQ:
mSocialApi.doShare(this, PlatformType.QQ, shareMedia, new MyShareListener());
break;

case R.id.radioShareQZone:
mSocialApi.doShare(this, PlatformType.QZONE, shareMedia, new MyShareListener());
break;

default:
return;
}
}

//微信分享
public void doShareWX(IShareMedia shareMedia) {
mSocialApi.doShare(this, PlatformType.WEIXIN, shareMedia, new ShareListener() {
@Override
public void onComplete(PlatformType platform_type) {
Log.i("tsy", "share onComplete");
}

@Override
public void onError(PlatformType platform_type, String err_msg) {
Log.i("tsy", "share onError:" + err_msg);
}
public class MyShareListener implements ShareListener {

@Override
public void onCancel(PlatformType platform_type) {
Log.i("tsy", "share onCancel");
}
});
}
@Override
public void onComplete(PlatformType platform_type) {
Log.i("tsy", "share onComplete");
}

//朋友圈分享
public void doShareWXCircle(IShareMedia shareMedia) {
mSocialApi.doShare(this, PlatformType.WEIXIN_CIRCLE, shareMedia, new ShareListener() {
@Override
public void onComplete(PlatformType platform_type) {
Log.i("tsy", "share onComplete");
}
@Override
public void onError(PlatformType platform_type, String err_msg) {
Log.i("tsy", "share onError:" + err_msg);
}

@Override
public void onError(PlatformType platform_type, String err_msg) {
Log.i("tsy", "share onError:" + err_msg);
}
@Override
public void onCancel(PlatformType platform_type) {
Log.i("tsy", "share onCancel");
}
}

@Override
public void onCancel(PlatformType platform_type) {
Log.i("tsy", "share onCancel");
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mSocialApi.onActivityResult(requestCode, resultCode, data);
}
}
}
17 changes: 17 additions & 0 deletions SampleCode/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
android:layout_marginTop="10dp"
android:text="微信登录" />

<Button
android:id="@+id/btnQQLogin"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/btnWXLogin"
android:text="QQ登录" />

</RelativeLayout>

<View
Expand Down Expand Up @@ -107,6 +116,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="朋友圈"/>
<RadioButton android:id="@+id/radioShareQQ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QQ"/>
<RadioButton android:id="@+id/radioShareQZone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QQ空间"/>
</RadioGroup>

<Button
Expand Down
Binary file added qq_mta-sdk-1.6.2.jar
Binary file not shown.
Binary file added qq_sdk_v3.1.0.jar
Binary file not shown.
Binary file removed social_sdk_v1.0.jar
Binary file not shown.
Binary file added social_sdk_v1.1.jar
Binary file not shown.

0 comments on commit 2767436

Please sign in to comment.