Chiamata http post a server remoto – Android snippet

Per effettuare una chiamata di tipo post ad un server remoto, utilizzare il seguente snippet:
dichiariamo due vRIbili:

 HttpClient clienthttp = new DefaultHttpClient();
 HttpPost urlpost = new HttpPost("http://www.tuosito.it/file.php");

richiamiamo così il nostro snippet

new eseguipost().execute();
 class eseguipost extends AsyncTask<String, String, String> {

	     	
	  	   @Override
	         protected void onPreExecute() {
	  		   
	  	  
	             super.onPreExecute();
	         
	             
	  	   }

		@Override
		protected String doInBackground(String... arg0) {
			// TODO Auto-generated method stub
			 List nameValuePairs = new ArrayList(2);
			    nameValuePairs.add(new BasicNameValuePair("valore1", "10"));
			    nameValuePairs.add(new BasicNameValuePair("valore2", "Android post"));
			    
	
			    try {
					urlpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			 
			    try {
					HttpResponse risposta = clienthttp.execute(urlpost);
				} catch (ClientProtocolException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			           
			return null;
		}
	 }