这篇文章的前提是,你已经按照官方文档、或者其他文档上的教程完整引入了ShareSDK的所有jar包、ShareSDk.xml,以及其他资源和各大平台的APPID的申请
如果大家在集成ShareSdk分享的时候,并且所有文件导入都正确的情况下,使用setCallBack()进行回调处理,发现分享成功后返回页面弹出分享取消的Toast。说明你入坑了。
首先,你的清单配置文件里(AndroidManifest.xml)里面是不是使用了下面这串官方文档的代码,
<activity
android:name="com.mob.tools.MobUIShell"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize" >
<intent-filter>
<data android:scheme="tencent100371282" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- 调用新浪原生SDK,需要注册的回调activity -->
<intent-filter>
<action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!--集成line客户端登录授权,需要添如下格式的过滤器-->
<intent-filter>
<data android:scheme="line.1477692153" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
如果是,那恭喜你入坑了。
已qq分享为例,你的过滤器<intent-filter>为起作用
你需要注册qq分享的Activty
<activity
android:name="cn.sharesdk.tencent.qq.ReceiveActivity"
android:launchMode="singleTask"
android:noHistory="true">
<intent-filter>
<data android:scheme="tencent(你的qqid)" /> //前面的tencent也需要
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
官方文档的意思是举个例子,具体分享平台的Activity注册和回调需要你自己添加。
如果这样处理了分享回调还是失败,你需要
1、检查你的qq AppId 和AppKey是不是正确,Share.xml里面也需要添加哦
2、setCallBack()要放在分享弹窗show();后面哦