网络权限请自行添加
- 项目跟包下创建wxapi包,并在该包下创建WXEntryActivity继承自WeChatSocialEntryActivity
假如我的包名为:io.github.socialhelper.demo,则该文件创建目录如下
package io.github.socialhelper.demo.wxapi
import io.github.devzwy.socialhelper.wechat.WeChatSocialEntryActivity
class WXEntryActivity : WeChatSocialEntryActivity() {
}
- 在AndroidManifest.xml文件中注册该页面
<activity android:name=".wxapi.WXEntryActivity"
android:launchMode="singleTask"
android:taskAffinity="把这里换成你的包名"
android:exported="true"/>
- 项目跟包下创建apshare包,并在该包下创建ShareEntryActivity继承自AlipaySocialEntryActivity
假如我的包名为:io.github.socialhelper.demo,则该文件创建目录如下
package io.github.socialhelper.demo.apshare
import io.github.devzwy.socialhelper.alipay.AlipaySocialEntryActivity
class ShareEntryActivity: AlipaySocialEntryActivity() {
}
- 在AndroidManifest.xml文件中注册该页面
<activity android:name=".apshare.ShareEntryActivity"
android:exported="true"/>
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
//加入这一行
if (requestCode == REQUEST_CODE_GOOGLE_AUTH) SocialHelper.onGoogleAuthResult(data)
}
- 在AndroidManifest.xml下的application标签加入如下代码
<application
//加入这两行
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:allowBackup"
>
- 调用授权Activity的onActivityResult中增加如下代码
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
//加入这一行
if (requestCode == REQUEST_CODE_LINE_AUTH) SocialHelper.onLineAuthResult(data)
}