How use and call AsyncTask into my code for upload data?

  

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);  //you 
should put here your temp variable
nameValuePairs.add(new BasicNameValuePair("temperature", String.valueOf(30)));
HttpPost request = post("http://mysite.com/temperature.php";, nameValuePairs);
DefaultHttpClient client = generateHttpClient();HttpResponse httpResponse = 
client.execute(request);

Where:

public static DefaultHttpClient generateHttpClient(){
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECTION);
        HttpConnectionParams.setSoTimeout(params, TIMEOUT_SOCKET);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", 
PlainSocketFactory.getSocketFactory(), 80));

        try{

KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);

        SSLSocketFactory sf = new EasySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(
               SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        registry.register(new Scheme("https", sf, 443));
    }catch (Exception e) {
        e.printStackTrace();
    }
//      params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,             
HttpVersion.HTTP_1_1);
    ClientConnectionManager cm = new ThreadSafeClientConnManager(params, 
registry);
    DefaultHttpClient client = new DefaultHttpClient(cm, params);
    client.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { 
        @Override 
        public long getKeepAliveDuration(HttpResponse response, HttpContext 
    context) { 
            return 60; // seconds 
        } 

    }); 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to