Java Code Examples for com.loopj.android.http.AsyncHttpClient#setCookieStore()

The following examples show how to use com.loopj.android.http.AsyncHttpClient#setCookieStore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyAsyncHttpClient.java    From school_shop with MIT License 6 votes vote down vote up
public static AsyncHttpClient createClient(Context context) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore cookieStore = new PersistentCookieStore(context);
    client.setCookieStore(cookieStore);

    return client;
}
 
Example 2
Source File: AskingFragmentActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle arg0) {
	// TODO Auto-generated method stub
	super.onCreate(arg0);
	setContentView(R.layout.question_pager);
	actionBar = getActionBar();
	actionBar.setIcon(null);
	actionBar.setTitle("提问");
	actionBar.setDisplayUseLogoEnabled(false);
	actionBar.setDisplayHomeAsUpEnabled(true);
	actionBar.show();
	text1 = new AskingFragment();
	text2 = new DetailFragment();
	text3 = new TagFragment();
	cursor = (ImageView) findViewById(R.id.cursor);
	attach_access_key = md5(getAttachKey());
	client = new AsyncHttpClient();
	myCookieStore = new PersistentCookieStore(this);
	client.setCookieStore(myCookieStore);
	progressDialog = new MyProgressDialog(this, "正在上传", "稍等...", false);
	InitTextView();
	InitImageView();
	InitViewPager();

}
 
Example 3
Source File: AsyncFileUpLoad.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
public AsyncFileUpLoad(Context context, String url, String filePath,
		CallBack callBack) {
	Log.i("url", url);
	Log.i("filePath", filePath);
	this.context = context;
	this.url = url;
	file = new File(filePath);
	NetworkState networkState = new NetworkState();
	client = new AsyncHttpClient();
	PersistentCookieStore mCookieStore = new PersistentCookieStore(context);
	client.setCookieStore(mCookieStore);
	if (networkState.isNetworkConnected(context)) {
		//Login();
		upLoad(callBack);
	} else {
		showTips(R.drawable.tips_error, R.string.net_break);
	}

}
 
Example 4
Source File: WriteAnswerActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.write_answer);
	actionBar = getActionBar();
	actionBar.setIcon(null);
	actionBar.setTitle("�ش�");
	actionBar.setDisplayUseLogoEnabled(false);
	actionBar.setDisplayHomeAsUpEnabled(true);
	actionBar.show();
	Intent intent = getIntent();
	question_id = intent.getStringExtra("questionid");
	attach_access_key = md5(getAttachKey());
	dp = getResources().getDimension(R.dimen.dp);
	editText = (EditText) findViewById(R.id.answerdetil);
	selectimg_horizontalScrollView = (HorizontalScrollView) findViewById(R.id.selectimg_horizontalScrollView);
	gridview = (GridView) findViewById(R.id.noScrollgridview);
	gridview.setSelector(new ColorDrawable(Color.TRANSPARENT));
	client = new AsyncHttpClient();
	myCookieStore = new PersistentCookieStore(this);
	client.setCookieStore(myCookieStore);
	progressDialog = new MyProgressDialog(this, "���ڼ�����", "���Ժ�...", false);
	gridviewInit();
}
 
Example 5
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP GET request with cookie which generate by own context
 *
 * @param context
 * @param url
 * @param responseHandler
 */
public static void getWithCookie(Context context, String url, AsyncHttpResponseHandler responseHandler) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    //  myCookieStore.clear();
    client.setCookieStore(myCookieStore);
    client.get(getAbsoluteUrl(url), responseHandler);

}
 
Example 6
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP GET request with cookies which are defined in hashmap
 *
 * @param context
 * @param url
 * @param hashMap
 * @param responseHandler
 */
public static void getUseCookie(Context context, String url, HashMap hashMap, AsyncHttpResponseHandler responseHandler) {
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    if (BasicUtils.judgeNotNull(hashMap)) {
        Iterator iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            Cookie cookie = new BasicClientCookie(key.toString(), value.toString());
            myCookieStore.addCookie(cookie);
        }
    }
    AsyncHttpClient client = new AsyncHttpClient();
    client.setCookieStore(myCookieStore);
    client.get(getAbsoluteUrl(url), responseHandler);
}
 
Example 7
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP POST request with cookie which generate by own context
 *
 * @param context
 * @param url
 * @param responseHandler
 */
public static void postWithCookie(Context context, String url, AsyncHttpResponseHandler responseHandler) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    //  myCookieStore.clear();
    client.setCookieStore(myCookieStore);
    client.post(getAbsoluteUrl(url), responseHandler);
}
 
Example 8
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP POST request with cookies which are defined in hashmap
 *
 * @param context
 * @param url
 * @param hashMap
 * @param responseHandler
 */
public static void postUseCookie(Context context, String url, HashMap hashMap, AsyncHttpResponseHandler responseHandler) {
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    if (BasicUtils.judgeNotNull(hashMap)) {
        Iterator iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            Cookie cookie = new BasicClientCookie(key.toString(), value.toString());
            myCookieStore.addCookie(cookie);
        }
    }
    AsyncHttpClient client = new AsyncHttpClient();
    client.setCookieStore(myCookieStore);
    client.post(getAbsoluteUrl(url), responseHandler);
}
 
Example 9
Source File: AsyncHttpHelper.java    From LiveVideo with Apache License 2.0 4 votes vote down vote up
/**
 * 设置持久化保存cookie
 */
public static void saveCookie(Context context) {
	AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
	PersistentCookieStore cookieStore = new PersistentCookieStore(context);
	asyncHttpClient.setCookieStore(cookieStore);
}
 
Example 10
Source File: EssayCommentActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.comment_list);

	ActionBar actionBar = getActionBar();
	actionBar.setIcon(null);
	actionBar.setTitle("��������");
	actionBar.setDisplayUseLogoEnabled(false);
	actionBar.setDisplayHomeAsUpEnabled(true);
	actionBar.show();
	Intent intent = getIntent();
	id = intent.getStringExtra("artid");
	client = new AsyncHttpClient();
	myCookieStore = new PersistentCookieStore(this);
	client.setCookieStore(myCookieStore);
	comment = (EditText) findViewById(R.id.comment);
	publish = (ImageButton) findViewById(R.id.publish);
	publish.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			RequestParams params = new RequestParams();
			params.put("article_id", id);
			params.put("message", comment.getText().toString());
			params.put("at_uid", atuid);
			postcom(params);
			comment.setText("");
			refresh();
		}
	});
	comitems = new ArrayList<EssayCommentModel>();
	imageDownLoader = new ImageDownLoader(this);
	comlist = (ListView) findViewById(R.id.comlist);
	isFirstEnter = true;
	comlist.setOnItemClickListener(this);
	comlist.setOnScrollListener(this);

	Getcom(id);

}
 
Example 11
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * Perform a HTTP GET request with cookie which generate by own context
 *
 * @param context
 * @param url
 * @param responseHandler
 */
public static void getWithCookie(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    client.setCookieStore(myCookieStore);
    client.get(getAbsoluteUrl(url), params, responseHandler);
}
 
Example 12
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * Perform a HTTP POST request with cookie which generate by own context
 *
 * @param context
 * @param url
 * @param params
 * @param responseHandler
 */
public static void postWithCookie(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    client.setCookieStore(myCookieStore);
    client.post(getAbsoluteUrl(url), params, responseHandler);
}