我是一名Android编程新手,希望将数据发送到PHP服务器并接收数据以在Android中显示。但我不知道如何创建它,也不知道如何使用库?您能给我一些实践的例子吗?
注:抱歉我的英语不好。
例如,我的PHP为“xxx.xxx.x.x/api.php”。
注:抱歉我的英语不好。
例如,我的PHP为“xxx.xxx.x.x/api.php”。
$keyword = $_GET['keyword'];
$index= $_GET['index'];
$path = "http://xxxxxxx/webservice/&query=".urlencode($keyword)."&index=".$index."";
$jsondata = file_get_contents($path);
$jsons = json_decode($jsondata,true);
echo json_encode($jsons);
我希望从EditText中发送关键字
和索引
到PHP服务器,并接收JSON数据以显示ListView。
"111.11.11/api.php"
,无法使用http://xxxxxxx/webservice/&query="....
。 - ARR.sreturn null
,无法从具有void结果类型的方法返回值。 - ARR.sconnect()
是多余的。输入流不能为 null,因此测试它是毫无意义的。异常应该传播给调用者,而不是被吞噬。 - user207421