1

我正在构建一个需要支持希伯来字母 (שלום) 的应用程序。我正在通过 GCM(谷歌云消息)发送消息。每当我OnMessage被称为我收到的字符串(希伯来语)时都是空的。

有什么简单的解决方法吗?提前致谢!

protected void onMessage(Context context, Intent intent) {
  String message = intent.getStringExtra(GCM_COMMAND);
  String action = intent.getAction();
  if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
    message = intent.getStringExtra(GCM_COMMAND);
    String s = message.toString();
    ItemBean ib =parseJson(s,context);
  }
  private ItemBean parseJson(String text,Context con) {
    ItemBean item = null;
    if (text != null) {
      JSONObject temp;
      try {
        temp = new JSONObject(text);
        String itemMessage = temp.get(GCM_MESSAGE).toString();
        //This String is Empty!
        String itemDate = temp.get(GCM_DATE).toString();
        long currentTime = System.currentTimeMillis();
        item = new ItemBean(currentTime,itemMessage,itemDate);
        sendNotification(con,itemMessage,itemDate);
      }
    }
    return item;
  }

来自 NetBeans 的服务器代码

JSONObject json = new JSONObject();
System.out.println("******גגגגגגשלום*********");
json.put(GCM_MESSAGE, ib.getmMessage());
//This is hebrew no problem!
json.put(GCM_DATE, ib.getmDate());
Message.Builder builder = new Message.Builder();
Message message = builder.build();
MulticastResult result = sender.send(message, listOfRegisteredDevices, 5);
int success = result.getSuccess();
4

1 回答 1

0

Can you try :

            String itemMessage = temp.getString(GCM_MESSAGE); 

and also

            json.put(GCM_MESSAGE, JSonObject.quote( ib.getmMessage() ) );
于 2012-11-18T09:22:23.947 回答