android第三方登录页面,android 第三方登录 QQ

1,jar包

2a01ee2fa3692e89e9b13ef4c4ff0770.png

2,配置AndroidManifest.xml

android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation">

android:name="com.tencent.tauth.AuthActivity"

android:launchMode="singleTask"

android:noHistory="true" >

android:name="com.tencent.connect.common.AssistActivity"

android:configChanges="orientation|keyboardHidden"

android:screenOrientation="behind"

android:theme="@android:style/Theme.Translucent.NoTitleBar" />

3,LoginActivity调用

//222222换成自己的appid

Tencent tencent;

public void login(){

tencent = Tencent.createInstance("222222",this.getApplicationContext());

tencent.login(this, "get_simple_userinfo",iUiListener);//all也可以

}

public IUiListener iUiListener = new IUiListener() {

@Override

public void onComplete(Object o) {

JSONObject response = (JSONObject)o;

DebugUtil.d("=="+response.toString());

//当前获取得是登陆信息openid之类的

//下边是获取用户信息userinfo

try {

//获得的数据是JSON格式的,获得你想获得的内容

//如果你不知道你能获得什么,看一下下面的LOG

DebugUtil.d("-------------"+response.toString());

DebugUtil.d( "openid-----"+response.getString("openid"));

DebugUtil.d( "access_token------"+response.getString("access_token"));

tencent.setOpenId(response.getString("openid"));

tencent.setAccessToken(response.getString("access_token"),

response.getString("expires_in"));

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

UserInfo userInfo = new UserInfo(getApplicationContext(),tencent.getQQToken());

userInfo.getUserInfo(new IUiListener() {

@Override

public void onComplete(Object o) {

JSONObject response = (JSONObject)o;

DebugUtil.d("22=="+response.toString());

}

@Override

public void onError(UiError uiError) {

}

@Override

public void onCancel() {

}

});

}

@Override

public void onError(UiError uiError) {

}

@Override

public void onCancel() {

}

};

//注销

//mTencent.logout(this);

4,回调

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

Tencent.onActivityResultData(requestCode, resultCode, data,iUiListener);

if(requestCode == Constants.REQUEST_API) {

if(resultCode == Constants.REQUEST_LOGIN) {

Tencent.handleResultData(data,iUiListener);

}

}

super.onActivityResult(requestCode, resultCode, data);

}

5.关于登陆绑定的unionid。即web和app获取的openid不一致时,需要打通数据获取unionid绑定q'q用户

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值