我需要我的 android 应用程序连接到 PHP 文件(只需在表格上进行选择并以 JSON 格式显示结果) 如何将我的应用程序连接到 php 文件并设置条件?例如:
JSON:
{"productos":[{"codeqr":"hola","actions":[]}
有条件的:
if (ResultPHP==hola){
//se encontró correctamente 'hola'
}else{
//no se encontró 'hola'
}
目前,我的连接代码是:
public class QRpost {
public static void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("qr.php");
try {
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream webs = entity.getContent();
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(webs,"iso-8859-1"),8);
webs.close();
}catch(Exception e){
Log.e("log_tag", "Error al convertir el resultado");
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}
有谁能够帮我?对不起我的英语不好 :(