<span style="font-size:24px;"> 获得QQ的信息,QQ头像和昵称</span>
private UMAuthListener umAuthListener = new UMAuthListener() { private String image_url,name; @Override public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) { Toast.makeText(LoginActivity.this, "Authorize succeed", Toast.LENGTH_SHORT).show(); mShareAPI.getPlatformInfo(LoginActivity.this, platform, new UMAuthListener() { @Override public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> data) { Set<String> set=data.keySet(); for (String string:set){ //设置头像 if (string.equals("profile_image_url")){ image_url = data.get(string); } //设置昵称 if (string.equals("screen_name")){ name = data.get(string); } } } @Override public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) { } @Override public void onCancel(SHARE_MEDIA share_media, int i) { } }); } @Override public void onError(SHARE_MEDIA platform, int action, Throwable t) { Toast.makeText(LoginActivity.this, "Authorize fail", Toast.LENGTH_SHORT).show(); } @Override public void onCancel(SHARE_MEDIA platform, int action) { Toast.makeText( LoginActivity.this, "Authorize cancel", Toast.LENGTH_SHORT).show(); } };
下面是主要的代码 ,千万不能忘!!!!!!
就是获得返回的信息的
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mShareAPI.onActivityResult(requestCode, resultCode, data);
}