I want to construct a JSON payload of this:
{
"aps": {
"badge": 15,
"alert": "Hello from Urban Airship!",
"sound": "cat.caf"
}
}
I tried with this thing :
JSONObject json = new JSONObject();
JSONObject badge=new JSONObject();
JSONObject alert=new JSONObject();
JSONObject sound=new JSONObject();
badge.put("badge",15);
json.put("aps",badge);
sound.put("sound",getResources().openRawResource(R.raw.cat));
json.put("aps",alert);
alert.put("alert", "Hello from Uday!");
json.put("aps",sound);
but it full payload is obtaining:when I print
am getting like half of payload like this:
{"aps":{"sound":"cat.caf"}}
its overriding, but
How do it in a correct way
Thanks
I am not sure what you are looking for, but considering that you want to create a JSON String.