android getUserById这个方法获取头像昵称,如果异步返回

使用异步回调但是不成功

EaseUI.getInstance().setUserProfileProvider(new EaseUI.EaseUserProfileProvider() { @Override public EaseUser getUser(String username) { return getUserById(username, context, new EaseUserProviderCallback() { @Override public EaseUser execUserMessage(EaseUser user) { // TODO Auto-generated method stub return user; } }); // LogUtil.e("easeUser:" + easeUser.getAvatar()); } });

OkHttpUtils.get().url(ApiUtils.getMemberHxName()). addParams("hxName", username). build().execute(new StringCallback() { @Override public void onError(Call call, Exception e, int id) { LogUtil.e("error = " +e.toString()); } @Override public void onResponse(String response, int id) { LogUtil.e(" patients success = " + response); EaseUser user = new EaseUser(username); try { JSONObject jsonObject= new JSONObject(response); user.setNick( jsonObject.getString("username")); user.setInitialLetter(jsonObject.getString("username")); user.setAvatar( jsonObject.getString("avatar")); user2=user; easeUserProviderCallback.execUserMessage(user); } catch (JSONException e) { e.printStackTrace(); } } });
 
已邀请:

lzan13

赞同来自:

你好,这个回调是实时的你异步操作,肯定不能返回数据给他,你可以参考这里实现:
http://www.imgeek.org/article/825308755

要回复问题请先登录注册

知识价值的认可,源自您的赞赏

扫描二维码,你的支付将由imGeek代收后转给对方

×