我在哪里接收我在android中从php发送的对象


where do i receive the objects i sent from php in android?

我有这个php代码,我不知道如何将我在代码末尾发送的所有数组都放在一个数组中,这样我就可以将这个数组发送给android?

$username = $_POST["username"];  
$locations_string = "";
$names = array();
$response1= array();
$response2= array();
$user_record = mysql_query("SELECT * FROM users WHERE username='$username'");
$value = mysql_fetch_array($user_record);
$userlocation = $value['location'];
$query = mysql_query("SELECT * FROM AllFriendsExceptBlocked WHERE username ='$username'       ");
while($row = mysql_fetch_array($query) ){
array_push($names , $value["friendname"]);
echo $row['friendname']. " - ". $row['location'];
echo "<br />";
}
for($i=0; $i < count($names) ; $i++){
$friend = $names[$i];
$user_record = mysql_query("SELECT * FROM AllFriendsExceptBlocked WHERE     friendname='$friend' ");
$value = mysql_fetch_array($user_record);
$locations_string = $locations_string . "," . $value['location'];
}
$response["message"] = "send locations of friends in AllFriendsExceptBlocked";
$response1["panicedUserLocation"] = $userlocation;
$response2["locations"] = $locations_string;
echo json_encode($response);
json_encode($response);
echo json_encode($response2);
json_encode($response2);
echo json_encode($response2);
json_encode($response2);

现在,我如何在android中接收我从php发送的响应?

从http调用中获取响应,尝试将响应转换为json对象。实例

InputStream JsonStream=responce.getEntity().getContent();
BufferedReader reader= new BufferedReader(new InputStreamReader(JsonStream));
StringBuilder builder = new StringBuilder();
String line;
while((line=reader.readLine())!=null)
{
    builder.append(line);
}
String JSONdata = builder.toString();
Log.i("JsonData",JSONdata);
JSONObject json = new JSONObject(JSONdata);