title: why my HTTP Request not working in Android OS 4.3 and below versions?
body: <p>I have an Android app, and it get the response from both webservices.The webservices written in PHP.
      Webservices Hosted in Live server and my request will be HTTP and HTTPS.Below the code working good in 
      Android 5.0,6.0,7.0, and i tested with 4.4.2 also its working nice. 
      but when i try to run my app in Android 4.3 my app will be crashed .</p>
  
  <p>what i have tried ,</p>
  
  <pre><code>try{
  
     String url = dRequestParam.getURL();
     HttpEntity httpEntity;
     HttpResponse httpResponse;
     DefaultHttpClient httpClient;
  
     if(url.startsWith("http://")){
      //http client
      httpClient = new DefaultHttpClient();
      httpEntity = null;
      httpResponse = null;
  
     }else{
  
      HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
  
      DefaultHttpClient client = new DefaultHttpClient();
  
      SchemeRegistry registry = new SchemeRegistry();
      SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
      socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
      registry.register(new Scheme("https", socketFactory, 443));
      SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
      httpClient = new DefaultHttpClient(mgr, client.getParams());
  
      HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
  
      int AdFetchTimeout=Integer.parseInt(AdView.getFetchTimeout());
      httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, AdFetchTimeout);
      httpEntity = null;
      httpResponse = null;
     }
              //checking http request method type
              if(method == POST){
                  HttpPost httpPost = new HttpPost();
                  //adding post params
                  if(params != null){
                      httpPost.setEntity(new UrlEncodedFormEntity(params));
                  }
                  httpResponse = httpClient.execute(httpPost);
              }else if(method == GET){
                  //appending params to url
                  params = AdRequestParam.getURL_PARAMS();
  
                  if(params != null){
                      String paramString = URLEncodedUtils.format(params,"utf-8");
                      url += "?" + paramString;
                  }
  
                  HttpGet httpGet = new HttpGet(url);
  
                  // SET HEADERS PARAMETERS
  
                  hParams = AdRequestParam.getHEADER_PARAMS();
  
                  for (NameValuePair nvp : hParams) {
                      String name = nvp.getName();
                      String value = nvp.getValue();
                      Cdlog.d(Cdlog.httpReqLogTag,name+"=&gt;"+value);
                      httpGet.setHeader(name,value);
                  }
                  Long startTime = null;
                  try {         
                      startTime = System.currentTimeMillis();
                      httpResponse = httpClient.execute(httpGet);
  
                      Cdlog.d(Cdlog.httpReqLogTag,url);
                      Cdlog.setLastRequest(url);
  
                      httpEntity = httpResponse.getEntity();
                      response = EntityUtils.toString(httpEntity);
                      Cdlog.d(Cdlog.httpResLogTag,response);
                      Cdlog.setLastResponse(response);
                    }
                    catch(SocketTimeoutException se) {
                      Long endTime = System.currentTimeMillis();
                      se.printStackTrace();
                    }          
                    catch(ConnectTimeoutException cte) {
                      Long endTime = System.currentTimeMillis();
                    response="{\"ad_available\":\"5\",\"ad_tag\":\"&lt;div&gt;&lt;/div&gt;\"}";
                      cte.printStackTrace();
                    }
                    catch (ClientProtocolException e) {            
                      e.printStackTrace();
                    }
                    catch (IOException e) {
                      Long endTime = System.currentTimeMillis();
  
                      e.printStackTrace();
                    }
                  //DAC125 Timeout Mechanism
  
              }
  
  
          }catch (UnsupportedEncodingException e){
              Log.d("Unsupported Encoding Exception",e.getMessage());
              e.printStackTrace();
          } catch (ClientProtocolException e){
              Log.d("Client Protocol Exception",e.getMessage());
              e.printStackTrace();
          } catch (IOException e){
              Log.d("IO Exception",e.getMessage());
              e.printStackTrace();
          } catch(SecurityException e){
              Log.d("Security Exception",e.getMessage());
              //response = e.getMessage();
              e.printStackTrace();
  
  
          }
  
          return response;
      }
  </code></pre>
  
  <p><strong>Logcat:</strong></p>
  
  <pre><code>01-18 10:49:22.552 6417-6417/? W/System.err: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Scheme 'http' not registered.
  
  63.   01-18 10:49:22.552 6417-6479/? W/dalvikvm: threadid=12: thread exiting with uncaught exception (group=0x415a1700)
  
  64.   01-18 10:49:22.552 6417-6417/? W/System.err:     at java.util.concurrent.FutureTask.report(FutureTask.java:94)
  
  65.   01-18 10:49:22.552 6417-6417/? W/System.err:     at java.util.concurrent.FutureTask.get(FutureTask.java:160)
  
  66.   01-18 10:49:22.552 6417-6417/? W/System.err:     at android.os.AsyncTask.get(AsyncTask.java:482)
  
  67.   01-18 10:49:22.552 6417-6417/? W/System.err:     at com.vrtcal.openfalls.adserver.AdFetcher$RequestHandler.handleMessage(AdFetcher.java:230)
  
  68.   01-18 10:49:22.552 6417-6417/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
  
  69.   01-18 10:49:22.552 6417-6417/? W/System.err:     at android.os.Looper.loop(Looper.java:137)
  
  70.   01-18 10:49:22.552 6417-6417/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5103)
  
  71.   01-18 10:49:22.552 6417-6417/? W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
  
  72.   01-18 10:49:22.552 6417-6417/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:525)
  </code></pre>