请教一下getJSONObjectAttribute
这个是我更改后的 但是还是获取不到
chat listener receive msg from:admin@easemob.com body:{"from":"admin","to":"u_13800138004","bodies":[{"msg":"李17申请加入09 的群组","type":"txt"}],"ext":{"messageType":4}}
这是我的获取代码
private class NewMessageBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// 主页面收到消息后,主要为了提示未读,实际消息内容需要到chat页面查看
Log.i("message", "聊天消息");
if(mSchoolPaperFragment!=null&&mSchoolPaperFragment.isVisible()){
((SchoolPaperFragment)mSchoolPaperFragment).refresh();
}
String from = intent.getStringExtra("from");
String msgId = intent.getStringExtra("msgid");
EMMessage message = EMChatManager.getInstance().getMessage(msgId);
try {
Log.i("message", "messagetype == "+message.getJSONObjectAttribute("ext"));
} catch (EaseMobException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
chat listener receive msg from:admin@easemob.com body:{"from":"admin","to":"u_13800138004","bodies":[{"msg":"李17申请加入09 的群组","type":"txt"}],"ext":{"messageType":4}}
这是我的获取代码
private class NewMessageBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// 主页面收到消息后,主要为了提示未读,实际消息内容需要到chat页面查看
Log.i("message", "聊天消息");
if(mSchoolPaperFragment!=null&&mSchoolPaperFragment.isVisible()){
((SchoolPaperFragment)mSchoolPaperFragment).refresh();
}
String from = intent.getStringExtra("from");
String msgId = intent.getStringExtra("msgid");
EMMessage message = EMChatManager.getInstance().getMessage(msgId);
try {
Log.i("message", "messagetype == "+message.getJSONObjectAttribute("ext"));
} catch (EaseMobException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
没有找到相关结果
已邀请:
1 个回复
beyond - imgeek运营
赞同来自: admin
1:没有写接收对象为单聊还是群聊
2:消息内容那里应该为msg,而不是bodies
3:接收消息对象应该是数组,而不是直接写
参考这个把
{"target_type":"users","from":"admin","target":["u_13800138004"],"msg":{"msg":"李17申请加入09 的群组","type":"txt"},"ext":{"messageType":4}}