其次:腾讯开放平台 是要应用上线到应用宝才能使用所有QQ登录(110406),否则就在应用调试者里添加QQ号码来测试,上限100个。有点山寨苹果哈。
1 mainfest XML配置Umeng key ,Umeng后台配置qq appid,appkey
2 mainfest XML配置qq appid
3 UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(LoginActivity.this,
"1104221086", "Ejx0a0hdRsO443Xq");
qqSsoHandler.addToSocialSDK();
4 mController.doOauthVerify(LoginActivity.this, SHARE_MEDIA.QQ,
new UMAuthListener() {
@Override
public void onError(SocializeException e,
SHARE_MEDIA platform) {
}
@Override
public void onComplete(Bundle value, SHARE_MEDIA platform) {
Toast.makeText(LoginActivity.this, "登录成功 正在加载...",
Toast.LENGTH_SHORT).show();
mController.getPlatformInfo(LoginActivity.this,
SHARE_MEDIA.QQ, new UMDataListener() {
@Override
public void onStart() {
}
@Override
public void onComplete(int status,
Map<String, Object> info) {
String tencentToken = "";
String uid = "";
// 成功获取平台信息
if (status == 200 && info != null) {
StringBuilder sb = new StringBuilder();
Set<String> keys = info
.keySet();
for (String kStr : keys) {
sb.append(kStr
+ "="
+ info.get(kStr)
.toString()
+ "\r\n");
if (kStr.equals("access_token")) {
tencentToken = info
.get(kStr)
.toString();
} else if (kStr
.equals("uid")) {
uid = info.get(kStr)
.toString();
}
}
UserUtil.thirdLogin(
LoginActivity.QQ_THIRDLOGIN_SIGN,
uid, tencentToken,
null, h);
Log.e("yan",
"平台信息" + sb.toString());
} else {
Log.e("yan", "发生错误");
}
}
});
}
@Override
public void onCancel(SHARE_MEDIA platform) {
}
@Override
public void onStart(SHARE_MEDIA platform) {
}
});
}