Android-async-http asynchttpclient Introduction

Source: Internet
Author: User

Asynchttpclient client =Newasynchttpclient (); Requestparamsparams=Newrequestparams ();params. put ("Key","value");params. put (" More","Data"); client.Get("http://www.google.com",params,NewAsynchttpresponsehandler () {@Override Public voidOnsuccess (intStatusCode, header[] headers,byte[] response) {System. out. println (response); } @Override Public voidOnFailure (intStatusCode, header[] headers,byte[] responsebody, throwable error) {LOG.D ("ERROR", error); }}); The above example is the case where the returned response is directly the original word stream, if you need to treat the returned result as a string, you only need to implement a texthttpresponsehandler anonymously. It inherits from Asynchttpresponse and converts the native byte stream into a string object based on the specified encoding, asynchttpclient client=Newasynchttpclient (); Requestparamsparams=Newrequestparams ();params. put ("Key","value");params. put (" More","Data"); client.Get("http://www.google.com",params,NewTexthttpresponsehandler () {@Override Public voidOnsuccess (intStatusCode, header[] headers, String response) {System. out. println (response); } @Override Public voidOnFailure (intStatusCode, header[] headers, String responsebody, throwable error) {LOG.D ("ERROR", error); }        });

Android-async-http asynchttpclient Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.