持久化cookie存储,保存cookie到你的应用程序的SharedPreferences
2.Installation
& Basic Usage(安装和基本用法)
Download the latest .jar file from github and place it in your Android app’s libs/
folder.
从github上下载最新的最新的jar文件.并将其放置在你的Android应用程序的libs /文件夹.
2.1下载方式:
1.从http://loopj.com/android-async-http/的页面下载
vcD4KPHA+CmxpYnJhcnk6wO/D5rTmt8W1xMrHYW5kcm9pZC1hc3luYy1odHRwv6rUtM/uxL+1xNS0wusot723qNK7o7q/ydLUsNFsaWJyYXJ5XHNyY1xtYWluXGphdmHOxLz+z8LD5rXEzsS8/r+9sbS1vaOsxOPTptPDtcRzcmPPwtKyv8nS1NaxvdPKudPDKTwvcD4KPHA+CnJlbGVhc2VzOsDvw+a05rfFtcTKx7j3uPaw5rG+tcRqYXLOxLz+o6wot723qLb+o7rWu9DosNHX7tDCtcRqYXLOxLz+v72xtLW9xOPTptPDtcRsaWJzxL/CvM/CvLS/yS4pPC9wPgo8cD4Kc2FtcGxlczrA78PmtOa3xbXE0rLKx8D919Mov8m5qbLOv7wpPC9wPgo8cD4KsbjXoqO6t723qNK7us23vbeotv7Wu8TcssnTw8bk1tDWrtK7o6y9qNLpssnTw7e9t6i2/jwvcD4KPHA+CjIuMsq508O3vbeoPC9wPgo8cD4KICBJbXBvcnQKIHRoZSBodHRwIHBhY2thZ2UuPC9wPgoKPHByZSBjbGFzcz0="brush:java;">import com.loopj.android.http.*;
Create a new AsyncHttpClient
instance and make a request:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println(response);
}
});
Adding GET/POST Parameters with RequestParams
The RequestParams
class is used to add optional GET or POST parameters to your requests.RequestParams
can
be built and constructed in various ways:
Create empty RequestParams
and immediately add some parameters:
RequestParams params = new RequestParams();
params.put("key", "value");
params.put("more", "data");
Create RequestParams
for a single parameter:
RequestParams params = new RequestParams("single", "value");
Create RequestParams
from an existing Map
of
key/value strings:
HashMap paramMap = new HashMap();
paramMap.put("key", "value");
RequestParams params = new RequestParams(paramMap);
See the RequestParams Javadoc for more information.
Add an InputStream
to the RequestParams
to
uploaAAAAAAAAAAre >InputStream myInputStream = blah;
RequestParams params = new RequestParams();
params.put("secret_passwords", myInputStream, "passwords.txt");
Add a File
object to the RequestParams
to
uploaAAAAAAAAAAre >File myFile = new File("/path/to/file.png");
RequestParams params = new RequestParams();
try {
params.put("profile_picture", myFile);
} catch(FileNotFoundException e) {}
Add a byte array to the RequestParams
to uploaAAAAAAAAAAre >byte[] myByteArray = blah;
RequestParams params = new RequestParams();
params.put("soundtrack", new ByteArrayInputStream(myByteArray), "she-wolf.mp3");
See the RequestParams Javadoc for more information.
Downloading Binary Data with BinaryHttpResponseHandler
The BinaryHttpResponseHandler
class can be used to fetch binary data such as images and other files. For example:
AsyncHttpClient client = new AsyncHttpClient();
String[] allowedContentTypes = new String[] { "image/png", "image/jpeg" };
client.get("http://example.com/file.png", new BinaryHttpResponseHandler(allowedContentTypes) {
@Override
public void onSuccess(byte[] fileData) {
// Do something with the file
}
});
See the BinaryHttpResponseHandler Javadoc for more information.
http://www.bkjia.com/Androidjc/777534.htmlwww.bkjia.comtruehttp://www.bkjia.com/Androidjc/777534.htmlTechArticleandroid-async-http开源项目可以是我们轻松的获取网络数据或者向服务器发送数据,使用起来非常简单,关于android-async-http开源项目的介绍内容...
本文源自: AG娱乐官网