title: Simple post request is not working in android 9
body: <p>I have an application that works fine on below <code>Android9 phones</code>. Recently I start testing my application on <code>android 9</code> and facing a strange problem that simple https/http post-call is not working and library(<code>com.loopj.android</code>) giving an exception that fails to connect. I know that there is a change related to network and I tried all the things which I find on the internet but still no luck. Here is my configuration:</p>
  
  <p><strong>Manifest.xml:</strong></p>
  
  <pre><code>  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;
          &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
          &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
          &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
          &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  
    &lt;application
           tools:targetApi="28"
           android:networkSecurityConfig="@xml/network_security_config"
           android:usesCleartextTraffic="true"&gt;
    &lt;/application&gt;
  </code></pre>
  
  <p><strong>network_security_config.xml</strong> in res/xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;network-security-config&gt;
      &lt;domain-config cleartextTrafficPermitted="true"&gt;
          &lt;domain includeSubdomains="true"&gt;my-backend.hostname.dk&lt;/domain&gt;
          &lt;trust-anchors&gt;
              &lt;certificates src="system" /&gt;
              &lt;certificates src="user" /&gt;
          &lt;/trust-anchors&gt;
      &lt;/domain-config&gt;
  &lt;/network-security-config&gt;
  </code></pre>
  
  <p>I am signing the app with proper Keystore:
  <strong>build.gradle:</strong></p>
  
  <pre><code>signingConfigs {
          release {
              storeFile file("../myApp-release.keystore")
              storePassword "abcd1234"
              keyAlias "myApp-release"
              keyPassword "abcd1234"
          }
      }
  </code></pre>
  
  <p>Also tried to use proper <strong>SSLFactory</strong> for httpclient:</p>
  
  <pre><code>AsyncHttpClient client = new AsyncHttpClient();
      try {
              KeyStore trustStore = MySSLSocketFactory.getKeystore();
              MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
              sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
             // MyCustomSSLFactory socketFactory = new MyCustomSSLFactory(trustStore);
  
              client.setSSLSocketFactory(sf);
              client.setTimeout(600000);
              client.setConnectTimeout(10000);
          } catch (Exception e) {
  
          }
  </code></pre>
  
  <p>Also tried to use SSL mentioned in this <a href="https://stackoverflow.com/a/42805905/8316275">post</a> but nothing is working for me and still getting an exception whenever my program try to call backend REST API. exception:</p>
  
  <pre><code>07-12 13:49:08.435 5111-5129/com.myapp.cherinstall W/System.err: java.net.SocketTimeoutException: failed to connect to my-backend.hostname.dk/192.168.4.24 (port 8182) from /192.168.3.246 (port 48880) after 10000ms
  </code></pre>
  
  <p>I have rooted the phone and running this code in an App that has no activity but the only intent service. I did some tests and figure out that if I run my HTTP request through activity(Create new Activity within the same Application for testing purpose) only once, then sending intent to this InteneService also start works but without invoking any Activity when application installed and sending IntentService call is failing. I know that there are more restrictions Google added in Android 9 and I don't know which one I am missing now. Can someone please give me a clue. </p>