Created
March 8, 2011 18:41
-
-
Save eyedol/860744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsonObject = new JSONObject(response); | |
JSONObject payloadObject = jsonObject.getJSONObject("payload"); | |
if (payloadObject != null) { | |
task = payloadObject.getString("task"); | |
if (task.equals("sendsms")) { | |
jsonArray = payloadObject.getJSONArray("messages"); | |
for (int index = 0; index < jsonArray.length(); ++index) { | |
jsonObject = jsonArray.getJSONObject(index); | |
sendSms(jsonObject.getString("to"), jsonObject.getString("message")); | |
} | |
Toast.makeText(context, "No: "+jsonArray.getJSONObject(0).getString("to")+"Messages :"+jsonArray.getJSONObject(0).getString("message"), Toast.LENGTH_LONG); | |
Log.i("SMSSYNC","No: "+jsonArray.getJSONObject(0).getString("to")+"Messages :"+jsonArray.getJSONObject(0).getString("message")); | |
} else { | |
// no task enabled on the callback url. | |
//showToast(context, R.string.no_task); | |
Log.i("SMSSYNC","No variable named sendsms"); | |
Toast.makeText(context, "No variable named sendsms", Toast.LENGTH_SHORT); | |
} | |
} else { | |
// no task is enabled on the callback url. | |
Toast.makeText(context, "No JSON string sent", Toast.LENGTH_SHORT); | |
//showToast(context, R.string.no_task); | |
} | |
} catch (JSONException e) { | |
Toast.makeText(context, "Invalid json string", Toast.LENGTH_SHORT); | |
Log.i("SMSSYNC","Invalid json string"); | |
//e.printStackTrace(); | |
//showToast(context, R.string.no_task); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment