这是我实现GCM推送通知的PHP代码,下面是我发送的数据
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array("message" => array( "id" => $id , "date" => $date , "performance" => $performance , "attendance" => $attendance ))
);
这是我从中获取值的android代码
Bundle extras = intent.getExtras();
String message = intent.getStringExtra("message");
这是json解析器类
json = new JSONObject("{message}");
stime = json.getString("performance");
name.setText(stime);
String slecturename = json.getString("attendance");
deal.setText(slecturename);
String sroom = json.getString("date");
valid.setText(sroom);
String sfaculty = json.getString("id");
address.setText(sfaculty);
在消息字段中,我得到的值为
{"id":"1","performance":"Poor","attendance":"Present","date":"2014-02-02"}
但是我无法用确切的ID解析它并获取值,我不知道我在哪里做错了。任何帮助将不胜感激
试试这个
json = new JSONObject(message);
代替
json = new JSONObject("{message}");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句