A
A.G
Neues Mitglied
- 0
Hallo Leute ich habe da eine frage .
Da ich schon sehr weit mit meine app bin habe ich ein Problem
Und zwar ich sende mit jeden switch einen link zur meine php datei die etwas einschaltet oder ausschaltet.
Jetzt brauche ich den Status ob der switch an oder aus ist ich speicher die werte in eine status.php
Für jeden Schalter wie bekomme ich den Wert zurück so das meine app sich alle paar Sekunden aktualisiert und die switch immer aktuell bleiben so das einer zweite Person die app anmacht und den Status der switch hat.
Ich Hofe man hat mich verstanden
Danke
Und das ist meine java classe
public class Network extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
ByteArrayOutputStream out = null;
try {
response = httpclient.execute(new HttpGet(uri[0]));
StatusLine statusLine = response.getStatusLine();
// HTTP RESPONSE CODES Server too busy/ nicht verfuegbar
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
responseString = out.toString();
} else {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return responseString;
}
}
Da ich schon sehr weit mit meine app bin habe ich ein Problem
Und zwar ich sende mit jeden switch einen link zur meine php datei die etwas einschaltet oder ausschaltet.
Jetzt brauche ich den Status ob der switch an oder aus ist ich speicher die werte in eine status.php
Für jeden Schalter wie bekomme ich den Wert zurück so das meine app sich alle paar Sekunden aktualisiert und die switch immer aktuell bleiben so das einer zweite Person die app anmacht und den Status der switch hat.
Ich Hofe man hat mich verstanden
Danke
Und das ist meine java classe
public class Network extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
ByteArrayOutputStream out = null;
try {
response = httpclient.execute(new HttpGet(uri[0]));
StatusLine statusLine = response.getStatusLine();
// HTTP RESPONSE CODES Server too busy/ nicht verfuegbar
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
responseString = out.toString();
} else {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return responseString;
}
}