【问题标题】:Retrieve values from notification using JSON PAYLOAD android使用 JSON PAYLOAD android 从通知中检索值
【发布时间】:2014-11-17 10:04:51
【问题描述】:

我处于一种情况,我的网络服务向我发送通知,其中包括

{
    "apiKey": "xxxxx-xxx-xxx-xxxx-xxxxxxx",
    "appKey": "xxxxx-xxx-xxx-xxxx-xxxxxxx",
    "sendAll": true,
    "content": {
        "subject": "Test Lottery",
        "message": "Notification Msg",
        "action": {
            "type": "DEFAULT",
            "data": "url|intent|...",
            "labe": "label"
        },
        "payload": "{'uid':'1','type':'LD'}",
        "sound": "default.caf",
        "badge": "+1"
    }
}

点击顶部出现的通知,我需要得到uidtype

我正在使用 Xtify 进行推送通知.....

【问题讨论】:

  • I am having a beginner knowledge in JSON 那么你必须扩展知识......
  • 离开那些有趣的 cmets .....如果可能的话帮助我...
  • 似乎不可能(帮助你)因为你懒得在提问之前使用google.com,这里有很多问题的重复......请在提问之前做一些研究
  • selvin 请允许其他人帮忙....
  • @karthik :这不是寻求帮助的一种方式............你是来帮忙的......如果你这样说话,没有人会帮助你......

标签: android jsonp xtify


【解决方案1】:

试试这个..

String JSON ="YOUR JSON RESULT STRING";
try {
    JSONObject jsonresult = new JSONObject(JSON);

    String apiKey= jsonresult.getString("apiKey");
    String appKey= jsonresult.getString("appKey");
    boolean sendAll= jsonresult.getBoolean("sendAll");

    JSONObject contentObject = jsonresult.getJSONObject("content");
    String subject= jsonresult.getString("subject");
    String message= jsonresult.getString("message");
    String sound= jsonresult.getString("sound");
    String badge= jsonresult.getString("badge");

    JSONObject actionObject = jsonresult.getJSONObject("action");

    String type= jsonresult.getString("type");
    String data= jsonresult.getString("data");
    String labe= jsonresult.getString("labe");

    JSONObject payloadObject = jsonresult.getJSONObject("payload");
    // do your code..

    }
} catch (JSONException e) {
    e.printStackTrace();
    //catching exceptions if any...
}

【讨论】:

  • 为什么?你为什么要回答?它是重复的,然后将其标记为重复
  • 我投了反对票,因为我不喜欢在这里已经有答案的问题上磨砺声誉
猜你喜欢
  • 2017-08-28
  • 2011-10-31
  • 2016-02-07
  • 2020-02-19
  • 1970-01-01
  • 1970-01-01
  • 2018-08-30
  • 2021-11-01
  • 1970-01-01
相关资源
最近更新 更多