I need to know how to pass an array from php to java. I can do the opposite thing: passing an array from java to php, but I dont know how to do the opposite. The code that i wrote is that:
`//php script
$response["success"] = 1;
$Id = {"1", "2"};
$response["Id"] = $Id;
echo json_encode($response);
`
//in java
int success = json.getInt("success");
ArrayList <Integer> Id = new ArrayList <Integer> ();
JSONArray jsonArray = json.getJSONArray("Id");
if (jsonArray != null) {
int len = jsonArray.length();
for (int i=0;i<len;i++){
Id.add(jsonArray.getInt(i));
}
}
On my script I pass several things to my android app, and I'm using the same json object to pass them. Should I use different json objects, one for some things and another for the array using a jsonarray? (the tag "success" is passed with no issues).
the only error I get is this: sendUserActionEvent() mView == null
But I think is something about the layout, so no matter with the question.