关于mob第三方登录的坑——微信篇

来源:互联网 发布:vb 中的structure 编辑:程序博客网 时间:2024/06/05 07:52

第一次用mob继承android的第三方登录,就踩到了个大坑,我是应该高兴还是高兴。

首先说说集成步骤:

1、准备工作:拷贝各种jar包到libs文件夹下面,拷贝ShareSDK.xml文件到asserts文件夹下面。

2、获取微信的第三方登录的AppId和AppSecret,分别替换掉ShareSDK.xml文件的默认数据。

    <Wechat        Id="4"        SortId="4"        AppId="wx****************"        AppSecret="53e*****************************"        BypassApproval="false"        Enable="true" />    <WechatMoments        Id="5"        SortId="5"        AppId="wx****************"        AppSecret="53e*****************************"        BypassApproval="false"        Enable="true" />    <WechatFavorite        Id="6"        SortId="6"        AppId="wx****************"        AppSecret="53e*****************************"        Enable="false" />

3、新建包:wxapi,在这个包下面新建类:WXEntryActivity, 这个类是微信客户端回调activity。不要忘记在 AndroidManifest.xml文件下注册:

     <activity            android:name="com.a.b.wxapi.WXEntryActivity"            android:configChanges="keyboardHidden|orientation|screenSize"            android:exported="true"            android:screenOrientation="portrait"            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

讲道理这时候微信第三方登录就搞定了,哈哈哈哈哈,坑来了:如果我们在微信第三方平台填写的包名和wxapi包前面的名称不一样的话,就会找不到回调类。比如在微信第三方平台填写包名是:com.a.b,而WXEntryActivity所属包是com.a.d.wxapi,这时候就会有问题了, 此时只需新建一个com.a.b.wxapi包,并把WXEntryActivity类放进去,问题就可以完美解决。

原创粉丝点击