AsyncHttpClient保持session

需求是用户登录后才可以获取列表

后台通过session判断用户是否登录

android端需要保持session信息

直接代码

AsyncHttpCilentUtil工具类

import android.content.Context;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.PersistentCookieStore;

public class AsyncHttpCilentUtil {

	private static AsyncHttpClient client;

	public static AsyncHttpClient getInstance(Context paramContext) {
		if (client == null) {
			client = new AsyncHttpClient();
			PersistentCookieStore myCookieStore = new PersistentCookieStore(paramContext);
			client.setCookieStore(myCookieStore);
		}
		return client;
	}
}


参考:AsyncHttpClient的CookieStore问题


你可能感兴趣的:(AsyncHttpClient保持session)