Suppongo tu stia utilizzando un php get o un post per comunicare con il server. Dovresti creare un url nella tua applicazione Android per connettersi allo script php sul server. Ad esempio, supponendo di avere uno script chiamato push.php sul server, questo si connetterebbe a login_url.com/push.phpYOURPOSTMESSAGEHERE:
//Pushes a line of data to the server
//Column reference: thing1, thing2, thing3, thing4, thing5
protected String push(String login_url, String[] params){
login_url+="/push.php";
try {
//This has to be inside the try/catch
URL url = new URL(login_url);
//See column reference at top of method
String col1 = params[1];
String col2 = params[2];
String col3=params[3];
String col4=params[4];
String col5=params[5];
// String col6=params[6]; //etc for more lines of data
//Opens a connection to the specified URL and reserves input/output privileges
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
//Opens a container for the data to transmit to the server
OutputStream outputStream = httpURLConnection.getOutputStream();
//Sends text in UTF-8 format, should be compliant with any SQL implementation
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
//Generates a string from the data
String post_data = URLEncoder.encode("thing1","UTF-8")+"="+URLEncoder.encode(col1,"UTF-8")+"&"
+URLEncoder.encode("thing2","UTF-8")+"="+URLEncoder.encode(col2,"UTF-8")+"&"
+URLEncoder.encode("thing3","UTF-8")+"="+URLEncoder.encode(col3,"UTF-8")+"&"
+URLEncoder.encode("thing4","UTF-8")+"="+URLEncoder.encode(col4,"UTF-8")+"&"
+URLEncoder.encode("thing5","UTF-8")+"="+URLEncoder.encode(col5,"UTF-8");
//Writes the data to the output and ships it over the http url connection
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
//Opens a container to receive input from the server
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String result="";
String line="";
while((line = bufferedReader.readLine())!= null) {
result += line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return result;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "push method or php error";
}