Android: Async-Http library


Android Asynchronous Http Client
A Callback-Based Http Client Library for Android
http://loopj.com/android-async-http/

Http Send:

// http send
AsyncHttpClient _clientPost = new AsyncHttpClient();

RequestParams params = new RequestParams();
params.put( "type", "" + type );
params.put( "text", message );
  
if( CookieManager.getInstance().getCookie(HttpAPI.uriAPI) != null )
{
     String cookieStr = CookieManager.getInstance().getCookie(HttpAPI.uriAPI);
           
     _clientPost.addHeader( "Cookie", cookieStr );
}
   
_clientPost.post( addr, params, new AsyncHttpResponseHandler() 
{
   @Override
   public void onSuccess(String response) 
   {
     try 
     { 
     
     }
      catch (JSONException e) 
      {
     
      }
       
   }

});

Http Get:

// http get
AsyncHttpResponseHandler _responseHandler = new AsyncHttpResponseHandler() 
{
  @Override
  public void onSuccess(String response) 
  {
  
  }
};

if( CookieManager.getInstance().getCookie(HttpAPI.uriAPI) != null )
{
   String cookieStr = CookieManager.getInstance().getCookie(HttpAPI.uriAPI);
           
   _clientGet.addHeader( "Cookie", cookieStr );
}
   
_clientGet.get( addr, responseHandler );

Comments

Popular posts from this blog

Drawing textured cube with Vulkan on Android

glTF loader for Android Vulkan

C++ unit testing & CI integration in GitHub (I/2)