我正在尝试将HTTP请求发送到我的web应用程序。但没有采取任何行动。我哪里错了?
class AsyncT extends AsyncTask<Void,Void,Void> {
@Override
protected Void doInBackground(Void... params){
try{
String url1 = "http://172.26.1.1/data/omnidrive";
URL url = new URL(url1);
HttpURLConnection httpURLConnection =
(HttpURLConnection)url.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.connect();
String data = "[0.10,0.00,0.00]";
DataOutputStream wr = new
DataOutputStream(httpURLConnection.getOutputStream());
wr.writeBytes(data);
wr.flush();
wr.close();
} catch (MalformedURLException e){
e.printStackTrace();
} catch(IOException e){
e.printStackTrace();
}
return null;
}
}
我期望在web应用程序中更新数据。
这就是我点击按钮后显示的内容。
误差
W/Settings:设置device_provisioned已从android.provider.Settings.Secure移动到android.provider.Settings.Global。V/HiTouch_HiTouch传感器:用户设置完成。D/NetworkSecurityConfig:没有指定网络安全Config,使用平台默认的I/ViewRootImpl: jank_removeInvalidNode,jank列表中的所有节点都过期了
发布于 2019-11-12 07:19:30
先在res文件夹下创建一个名为network_security_config
.
android:networkSecurityConfig="@xml/network_security_config"
发布于 2019-11-12 07:48:02
Use应该在XML android:usesCleartextTraffic="true"
标记中声明application
。它用于指示应用程序是否打算使用明文网络流量,例如明文HTTP。欲了解更多信息,请访问本网站:https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic
https://stackoverflow.com/questions/58813684
复制相似问题