你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
ebpangyong
美国队长
eoeduo@163.com
lyuzhao
要回复问题请先登录或注册
4 个回复
ebpangyong
透传消息只是通知,收到透传消息之后去执行你定义好的action 动作
http://easemob.com/docs/android/payload/#section
http://easemob.com/docs/ios/IOSSDKMessage/#cmdalloc
美国队长
透传消息能做什么:头像,昵称的更新等,可以把透传消息理解为一条指令,通过发送这条指令给对方,告诉对方 ...
超详细啊,赞一个
eoeduo@163.com
透传消息能做什么:头像,昵称的更新等,可以把透传消息理解为一条指令,通过发送这条指令给对方,告诉对方 ...
(Android问题)感谢回答,我在Fragment中通过透传消息更改用户头像,图片是上传到LeanCloud上面的,我在广播的通过user.setAvatar(attr)将图片的url设置进去,然后在onCreateView中user.getAvatar得到的是空的,这是为什么啊?相关代码:
/**
* 透传消息BroadcastReceiver
*/
private BroadcastReceiver cmdMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
abortBroadcast();
// 获取cmd message对象
String msgId = intent.getStringExtra("msgid");
EMMessage message = intent.getParcelableExtra("message");
// 获取消息body
CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody();
String action = cmdMsgBody.action;// 获取自定义action
try {
String attr = message.getStringAttribute("avatar_key");
user.setAvatar(attr);
} catch (EaseMobException e) {
e.printStackTrace();
}
}
};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View fragmentView = getView();
avatarView = (ImageView) fragmentView.findViewById(R.id.avatar);
avatarView.setOnClickListener(this);
// 注册一个透传消息的BroadcastReceiver
IntentFilter cmdMessageIntentFilter = new IntentFilter(EMChatManager
.getInstance().getCmdMessageBroadcastAction());
cmdMessageIntentFilter.setPriority(13);
getActivity().registerReceiver(cmdMessageReceiver,
cmdMessageIntentFilter);
refresh();
}
private void refresh() {
String avatar = user.getAvatar();
if (avatar == null) {
return;
} else {
UserService.displayAvatar(avatar, avatarView);
}
}
lyuzhao
http://www.easemob.com/docs/android/advanced/