0

I'm trying to post HTTP request to my web application. But there is no action done. Where am I wrong?

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;
    }
}

I expected the data to be updated in the web application.

This is what it shows after I clicked the button

Error

W/Settings: Setting device_provisioned has moved from android.provider.Settings.Secure to android.provider.Settings.Global. V/HiTouch_HiTouchSensor: User setup is finished. D/NetworkSecurityConfig: No Network Security Config specified, using platform default I/ViewRootImpl: jank_removeInvalidNode all the node in jank list is out of time

CodeWithVikas
  • 1,105
  • 9
  • 33
  • refer https://stackoverflow.com/questions/39933345/no-network-security-config-specified-using-platform-default-android-log – sasikumar Nov 12 '19 at 07:14

2 Answers2

2
  • Try this one might help you.

  • First of create one Folder under res folder named it xml then in that folder create one xml file name network_security_config.

  • Then Add below lines of code in that xml file.

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
        <domain-config cleartextTrafficPermitted="true">
            <domain includeSubdomains="true">your url</domain>
        </domain-config>
    </network-security-config>
    
  • Then below line in application tag in Manifest file.

    android:networkSecurityConfig="@xml/network_security_config"
    
Parth Lotia
  • 753
  • 1
  • 7
  • 25
0

Use should declare android:usesCleartextTraffic="true" inside XML application tag. It is used to indicate whether the app intends to use cleartext network traffic, such as cleartext HTTP. For more information, please visit this site: https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic

TaQuangTu
  • 2,155
  • 2
  • 16
  • 30