Ich versuche zu finden, wie man einige HTTP-Anfrage in Android 6.0,
Seit Android auf die Version 6.0 gehen, kann ich nichts finden, um mir mit den 6.0 Änderungen zu helfen .Wie erstelle ich HTTP-Anfrage in Android 6.0
ich eine HTTP-Anforderung an einen REST Api tun möchte nur ohne irgendwelche Abhängigkeiten
Ich habe dies getan, aber seine Rückkehr mir 405 statt 200.
@Override
protected Object doInBackground(Object[] params) {
public String rest_Url = "https://balblabla" ;
HttpURLConnection client = null;
try {
URL url = new URL(rest_Url);
client = (HttpURLConnection) url.openConnection();
if (client != null){
client.setRequestMethod("GET");
// client.setRequestProperty("Accept-Encoding", "identity");
client.setDoOutput(true);
}
OutputStream outputPost = new BufferedOutputStream(client.getOutputStream());
outputPost.flush();
if (outputPost!= null){outputPost.close();}
int responseCode = client.getResponseCode();
if (responseCode != 200){
String failure = "ECHEC";
System.out.println(failure);
}else {
String success = "BRAVO";
System.out.println(success);
}
} catch (IOException e) {e.printStackTrace();}
finally {
if(client != null){
client.disconnect();
}
}
return null;`
Vielen Dank für Ihre Antworten.
https://stackoverflow.com/questions/32949626/org-apache-http-entity-filentity-is-reprecated-in-android-6-marshmallow – CommonsWare