title: Android sending HTTP POST request to the server
body: <p>I'm creating an application that connects to the cakePHP website
  I create a default HTTP client and send a HTTP POST request to the server.
  The data is coming from the server in json format, and in the client side I take the value from the json array, this is my project structure.
  Below I show some code that I used to connect with server</p>
  
  <pre><code>        try{
               HttpClient httpclient = new DefaultHttpClient();
               HttpPost httppost = new HttpPost("http://10.0.2.2/XXXX/logins/login1");
  
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
          response = httpclient.execute(httppost);
          StringBuilder builder = new StringBuilder();
                 BufferedReader   reader = new BufferedReader
  
              (new     InputStreamReader(response.getEntity().getContent(), "UTF-8"));
  
                for (String line = null; (line = reader.readLine()) != null;) 
  
                      {
                      builder.append(line).append("\n");
                      }
  
                JSONTokener   tokener = new JSONTokener(builder.toString());
                JSONArray  finalResult = new JSONArray(tokener);
                System.out.println("finalresulttttttt"+finalResult.toString());
                System.out.println("finalresul length"+finalResult.length());
                  Object type = new Object();
  
                if (finalResult.length() == 0 &amp;&amp; type.equals("both")) 
              {
          System.out.println("null value in the json array");
  
  
                  }
      else {
  
             JSONObject   json_data = new JSONObject();
  
              for (int i = 0; i &lt; finalResult.length(); i++) 
                 {
                     json_data = finalResult.getJSONObject(i);
  
                     JSONObject menuObject = json_data.getJSONObject("Userprofile");
  
                     group_id= menuObject.getString("group_id");
                     id = menuObject.getString("id");
                     name = menuObject.getString("name");
                  }
                      }
                          }
  
  
                    catch (Exception e) {
                 Toast.makeText(FirstMain.this,"exceptionnnnn",Toast.LENGTH_LONG).show();
                   e.printStackTrace();
                      }
  </code></pre>
  
  <p>My problem is </p>
  
  <ol>
  <li>I need to connect every page with the server, for that I need to write the code every time in my all activity, is there any other way to make a connection to the server and send a request from every activity? The concept of an interface is something like....</li>
  <li>Is there any class  that is supplied by the android library for connecting to the server?</li>
  <li><p>Is any need to check all verification such as an SSL certificate such as in the client-side?</p></li>
  <li><p>Are there any additional requirements needed for connecting to a server from android?</p></li>
  <li><p>What is the need of implementing services like SOAP REST for interaction with the server</p></li>
  </ol>
  
  <p>I'm a fresher in this field.. please give me answer for my  doubts..
  And please support me... </p>