⑴ android 怎么从httpResponse获取cookie
HttpRequest类和HttpResponse类提供了Cookie属性,可以获取你要的信息
然后你要显示的控件。text=这个内容
⑵ 安卓Android开发,afinal中的FinalHttp如何获取和设置cookie
1.获取
finalHttp = new FinalHttp();
finalHttp.post(API.server, ajaxParams, new AjaxCallBack<String>() {
@Override public void onFailure(Throwable t, int errorNo, String strMsg) { super.onFailure(t, errorNo, strMsg);
closeProgressDialog();
prompt(getResources().getString(R.string.request_time_out));
System.out.println("errorNo:" + errorNo + ",strMsg:" + strMsg);
}
@Override public void onStart() { super.onStart();
showProgressDialog(getResources().getString(R.string.loading));
}
@Override public void onLoading(long count, long current) { super.onLoading(count, current);
}
@Override public void onSuccess(String t) { super.onSuccess(t); //从服务器获取CookieStore,保存到MyCookieStore
DefaultHttpClient client=(DefaultHttpClient)finalHttp.getHttpClient();
MyCookieStore.cookieStore = client.getCookieStore(); if (!StringUtils.isBlank(t)) {
Log.e(TAG, Constant.RESULT + API.GET_VERIFY_CODE + "
" + t.toString());
JSONStatus jsonStatus = BaseJSONData(t); if (jsonStatus.isSuccess) {
handler.sendMessage(handler.obtainMessage(GET_VERIFY_CODE_SUCCESS, BaseJSONData(t)));
} else {
handler.sendMessage(handler.obtainMessage(GET_VERIFY_CODE_FALSE, BaseJSONData(t)));
}
} else {
prompt(getResources().getString(R.string.request_no_data));
}
}
});
2.设置
OverridepublicvoidinitData() {finalHttp =newFinalHttp();//配置已保存的CookieStore,保证处于同一session中请求finalHttp.configCookieStore(MyCookieStore.cookieStore);finalHttp.post(API.server, ajaxParams,newAjaxCallBack<String>() {......(省略)}}
格式不行,凑合看吧
点赞+关注谢谢