第三方登陆
第三方登陆
miao了个咪 发表于1年前
第三方登陆
  • 发表于 1年前
  • 阅读 4
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

public class MainActivity extends Activity {

private UMShareAPI mShareAPI;

protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	mShareAPI = UMShareAPI.get(this);

}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	mShareAPI.onActivityResult(requestCode, resultCode, data);
}

public void QQ(View v) {

	SHARE_MEDIA platform = SHARE_MEDIA.QQ;
	mShareAPI.doOauthVerify(this, platform, umAuthListener);
}

private UMAuthListener umAuthListener = new UMAuthListener() {
	
	//成功
	public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
		if (action == UMAuthListener.ACTION_GET_PROFILE) {
			//获取用户信息
			Log.e("","data=" + data);
			//头像
			String avatar = data.get("profile_image_url");
			//昵称
			String nickName = data.get("screen_name");
			//省份
			String province = data.get("province");
			//性别
			String sex = data.get("gender");
			
		} else if (action == UMAuthListener.ACTION_AUTHORIZE) {
			// 授权登录成功
			mShareAPI.getPlatformInfo(MainActivity.this, platform, umAuthListener);
			Toast.makeText(getApplicationContext(), "Authorize succeed", Toast.LENGTH_SHORT).show();
		}
	}

	public void onError(SHARE_MEDIA platform, int action, Throwable t) {
		Toast.makeText(getApplicationContext(), "Authorize fail", Toast.LENGTH_SHORT).show();
	}

	public void onCancel(SHARE_MEDIA platform, int action) {
		Toast.makeText(getApplicationContext(), "Authorize cancel", Toast.LENGTH_SHORT).show();
	}
};

}

共有 人打赏支持
粉丝 3
博文 10
码字总数 3187
×
miao了个咪
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: