Ich bin nicht vertraut mit der HttpUrlConnection auf Android Studio. Ich habe versucht, mit HttpClient in Eclipse zu codieren und es funktioniert. HttpClient ist jetzt in Android Studio veraltet, also habe ich versucht, es mit der HttpUrlConnection zu ändern. Mein Code in Android Studio ist wie folgt:HttpUrlConnection in Android kein Fehler, aber nicht funktioniert
public String LedOff(View view) {
try {
URL url = new URL("http://192.168.4.1/LEDOff");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
in Eclipse es so ist:
public void LedOff (View view){
String url = "http://192.168.4.1/LEDOff";
HttpClient httpClient = new DefaultHttpClient();
try {
httpClient.execute(new HttpGet(url));
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Ich weiß nicht, was los ist. Bitte hilf mir, Jungs. Vielen Dank.
bitte Ihre logcat einfügen .. – prat
Sind Sie hinter einem Proxy? –
05-19 15: 27: 12,727 21143-21150/com.ganda.alex.http D/jdwp: handlePacket: cmd = 0x1, cmdSet = 0xC7, len = 0x14, id = 0x400067C7, flags = 0x0, dataLen = 0x9 05-19 15: 27: 12,727 21143-21150/com.ganda.alex.http D/jdwp: sendBufferedRequest: len = 0x34 05-19 15: 27: 13,228 21143-21150/com.ganda.alex.http D/jdwp: processIncoming mein Logcat ist einfach so über alle – Alexxx