title: Http Post not working (Android)
body: <p>My code works fine on android 2.2 but doesn't work on Android 4+.Does anybody know what's the problem.I tried it on the android simulator and my phone.P.S I have put the internet permission.</p>
  
  <pre><code>      protected void postData2(){
  
      HttpURLConnection connection;
         OutputStreamWriter request = null;
  
              URL url = null;   
              String response = null;         
              String parameters = "Post Data Here";   
  
  
              try
              {
  
                  url = new URL ("URL");
  
                  connection = (HttpURLConnection) url.openConnection();
                  connection.setDoOutput(true);
                  connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                  connection.setRequestMethod("POST");    
  
                  request = new OutputStreamWriter(connection.getOutputStream());
                  request.write(parameters);
                  request.flush();
                  request.close();            
                 String line = "";               
                  InputStreamReader isr = new InputStreamReader(connection.getInputStream());
                  BufferedReader reader = new BufferedReader(isr);
                  StringBuilder sb = new StringBuilder();
                  while ((line = reader.readLine()) != null)
                  {
                      sb.append(line);
                  }
                  // Response from server after login process will be stored in response variable.                
                  response = sb.toString();
                  // You can perform UI operations here
                  Toast.makeText(this,"Message from Server: \n"+ response, 0).show();             
                  isr.close();
                  reader.close();
  
  
              }
              catch(IOException e)
              {
                  // Error
              }
                  }
  </code></pre>