title: HttpURLConnection working on Android 6.X (Elephone P9000) but not on Android 4.X (Samsung G S3)
body: <p>With the exact same code an HTTURLConnection is not working on my Samsung Galaxy S3(v4.x), but it does on on my Elephone P9000 (v6.x).</p>
  
  <p>On the Galaxy I get a 400 response code.</p>
  
  <p>Here is my snippet. Help will be greatly appreciated.</p>
  
  <pre><code>class Request extends AsyncTask&lt;Void, Void, Response&gt; {
  
      private Exception exception;
  
      protected void onPreExecute() {
          progressBar.setVisibility(View.VISIBLE);
      }
  
      protected Response doInBackground(Void... urls) {
          try {
              URL url = new URL(API_URL + "email=" +URLEncoder.encode(Email, "utf-8") + "&amp;password=" + URLEncoder.encode(Password, "utf-8"));                
              HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
              Log.d("Response Code: ", String.valueOf(urlConnection.getResponseCode()));
              Log.d("Error Body: ", String.valueOf(urlConnection.getErrorStream()));
              try {
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                  StringBuilder stringBuilder = new StringBuilder();
                  String line;
                  while ((line = bufferedReader.readLine()) != null) {
                      stringBuilder.append(line).append("\n");
                  }
                  bufferedReader.close();
  
                  //Parse Response
                  Log.d("Response", stringBuilder.toString());
                  JSONObject object = (JSONObject) new JSONTokener(stringBuilder.toString()).nextValue();
                  Response res = new Response();
  
                  res.setStatus(object.getString("status"));
                  res.setUserID(object.getString("UserID"));
                  res.setError(object.getString("error"));
  
                  Log.d("Req Response obj Status",res.getStatus() );
  
  
                  return res;
              }
              finally{
                  urlConnection.disconnect();
              }
          }
          catch(Exception e) {
              Log.e("ERROR", e.getMessage(), e);
              return null;
          }
  
      }
  
  
  }
  </code></pre>