1:去友盟下载jar和相关文件
2:导入工程
3:配置信息
注意代码这里配置的回调地址需要和微博开放平台授权回调页保持一致
PlatformConfig.setWeixin("wxa7a60fb129dce8a2", "595ec15ae27a4d208292605d53de74cf");
清单文件配置:友盟的appkey等和微信的回调等信息
4:调用
case R.id.loginWeiChat:
if (!APP.mShareAPI.isInstall(this, SHARE_MEDIA.WEIXIN)) {
T.showCenter(mContext, R.string.uninstall, Toast.LENGTH_SHORT);
return;
}
APP.mShareAPI.getPlatformInfo(mActivity, SHARE_MEDIA.WEIXIN, umAuthListener);
break;
回调:
private UMAuthListener umAuthListener = new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA platform) {
//授权开始的回调
buildProgressDialog();
}
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
cancelProgressDialog();
//当前第三方登录的名称 QQ or WeChat or SINA
currentLoginPlatformName = platform.toString();
//所在平台的昵称
String platformNickName = data.get("name");
//所在平台头像的URL
platformAvatarUrl = data.get("iconurl");
//所在平台的性别
String platformGender = data.get("gender");
// uid
platformUid = data.get("uid");
Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show();
updateThirdLoginInfo();
}
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
T.showShort(mContext, R.string.auth_filed);
cancelProgressDialog();
}
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
T.showShort(mContext, R.string.auth_cancle);
cancelProgressDialog();
}
};
2:导入工程
3:配置信息
注意代码这里配置的回调地址需要和微博开放平台授权回调页保持一致
PlatformConfig.setWeixin("wxa7a60fb129dce8a2", "595ec15ae27a4d208292605d53de74cf");
清单文件配置:友盟的appkey等和微信的回调等信息
4:调用
case R.id.loginWeiChat:
if (!APP.mShareAPI.isInstall(this, SHARE_MEDIA.WEIXIN)) {
T.showCenter(mContext, R.string.uninstall, Toast.LENGTH_SHORT);
return;
}
APP.mShareAPI.getPlatformInfo(mActivity, SHARE_MEDIA.WEIXIN, umAuthListener);
break;
回调:
private UMAuthListener umAuthListener = new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA platform) {
//授权开始的回调
buildProgressDialog();
}
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
cancelProgressDialog();
//当前第三方登录的名称 QQ or WeChat or SINA
currentLoginPlatformName = platform.toString();
//所在平台的昵称
String platformNickName = data.get("name");
//所在平台头像的URL
platformAvatarUrl = data.get("iconurl");
//所在平台的性别
String platformGender = data.get("gender");
// uid
platformUid = data.get("uid");
Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show();
updateThirdLoginInfo();
}
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
T.showShort(mContext, R.string.auth_filed);
cancelProgressDialog();
}
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
T.showShort(mContext, R.string.auth_cancle);
cancelProgressDialog();
}
};