本文整理汇总了Java中com.loopj.android.http.PersistentCookieStore类的典型用法代码示例。如果您正苦于以下问题:Java PersistentCookieStore类的具体用法?Java PersistentCookieStore怎么用?Java PersistentCookieStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersistentCookieStore类属于com.loopj.android.http包,在下文中一共展示了PersistentCookieStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// 注册App异常崩溃处理器
// Thread.setDefaultUncaughtExceptionHandler(AppException.getAppExceptionHandler());
CacheManager.initCacheDir(Constants.CACHE_DIR, getApplicationContext(),
new DBHelper(getApplicationContext(), 1, "app_cache", null, null));
instance = this;
AsyncHttpClient client = new AsyncHttpClient();
PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
client.setCookieStore(myCookieStore);
ApiHttpClient.setHttpClient(client);
ApiHttpClient.setCookie(ApiHttpClient.getCookie(this));
EmojiHelper.initEmojis();
initImageLoader(this);
MobclickAgent.setDebugMode(false);
UpdateConfig.setDebug(false);
requestDailyEnglish();
}
示例2: createConnection
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
HttpURLConnection conn = super.createConnection(url, extra);
if (url.startsWith(Global.HOST)) {
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
List<Cookie> cookies = cookieStore.getCookies();
String sid = "";
for (Cookie item : cookies) {
if (item.getName().equals("sid")) {
sid = "sid=" + item.getValue();
break;
}
}
conn.setRequestProperty("Cookie", sid);
}
return conn;
}
示例3: createClient
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
public static AsyncHttpClient createClient(Context context) {
AsyncHttpClient client = new AsyncHttpClient();
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
client.setCookieStore(cookieStore);
if (!Global.HOST.equals(Global.DEFAULT_HOST)) {
AccountInfo.CustomHost customHost = AccountInfo.getCustomHost(context);
client.addHeader("Authorization", customHost.getCode()); // 有可能会有密码
}
for (String item : mapHeaders.keySet()) {
client.addHeader(item, mapHeaders.get(item));
}
client.setTimeout(60 * 1000);
return client;
}
示例4: syncCookie
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
public static void syncCookie(Context context) {
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
List<Cookie> cookies = cookieStore.getCookies();
CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
for (int i = 0; i < cookies.size(); i++) {
Cookie eachCookie = cookies.get(i);
cookieManager.setCookie(Global.HOST, String.format("%s=%s; Domain=%s; Path=%s; Secure; HttpOnly",
eachCookie.getName(), eachCookie.getValue(), eachCookie.getDomain(),
eachCookie.getPath()));
}
CookieSyncManager.getInstance().sync();
}
示例5: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
httpClient = new AsyncHttpClient();
PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
httpClient.setCookieStore(myCookieStore);
httpClient.setTimeout(10000);
fragmentManager = getSupportFragmentManager();
setContentView();
loadDialog = getRequestDg(this);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
initViews();
initHead();
initDatas();
setDatas();
setListener();
}
示例6: PantipRestClient
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
public PantipRestClient(Context context) {
this.context = context;
client = new AsyncHttpClient();
PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
client.setCookieStore(myCookieStore);
client.setMaxRetriesAndTimeout(2, 10);
client.addHeader("origin", "http://pantip.com");
client.addHeader("Content-Type", "application/x-www-form-urlencoded");
client.addHeader("X-Requested-With", "XMLHttpRequest");
client.addHeader("Accept", "application/json, text/javascript, */*; q=0.01");
client.addHeader("Accept-Encoding", "gzip,deflate,sdch");
client.addHeader(
"User-Agent",
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"
);
client.addHeader("Referer", "http://pantip.com/login?redirect=Lw==");
client.addHeader("Accept-Language", "en-US,en;q=0.8,th;q=0.6");
}
示例7: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
PersistentCookieStore cookieStore = new PersistentCookieStore(
WelcomeActivity.this);
FanfanSharedPreferences fanfanSharedPreferences = new FanfanSharedPreferences(
WelcomeActivity.this);
boolean LoginStatus = fanfanSharedPreferences.getLogInStatus(false);
String uid = fanfanSharedPreferences.getUid("");
String userName = fanfanSharedPreferences.getUserName("");
String passwd = fanfanSharedPreferences.getPasswd("");
if (LoginStatus != false && !uid.equals("") && !passwd.equals("")
&& !userName.equals("") && cookieStore.getCookies().size() != 0) {
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.welcome);
init();
}
示例8: onOptionsItemSelected
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
// �û�������ť
if (id == R.id.feedback) {
FeedbackAgent agent = new FeedbackAgent(MainActivity.this);
agent.startFeedbackActivity();
}
if (id == R.id.logout) {
sharedPreferences.clear();
PersistentCookieStore cookieStore = new PersistentCookieStore(
MainActivity.this);
cookieStore.clear();
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
示例9: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@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();
}
示例10: AsyncFileUpLoad
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
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);
}
}
示例11: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@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();
}
示例12: getUseCookie
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
/**
* 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);
}
示例13: postUseCookie
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
/**
* 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);
}
示例14: onCreate
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// 注册App异常崩溃处理器
// Thread.setDefaultUncaughtExceptionHandler(AppException.getAppExceptionHandler());
instance = this;
init2();
AsyncHttpClient client = new AsyncHttpClient();
PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
client.setCookieStore(myCookieStore);
ApiHttpClient.setHttpClient(client);
ApiHttpClient.setCookie(ApiHttpClient.getCookie(this));
EmojiHelper.initEmojis();
initImageLoader(this);
MobclickAgent.setDebugMode(false);
UpdateConfig.setDebug(false);
requestDailyEnglish();
}
示例15: init
import com.loopj.android.http.PersistentCookieStore; //导入依赖的package包/类
/**
* Resource initialization.
* @param context Context
*/
protected static void init(Context context) {
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
client.setCookieStore(cookieStore);
if (USER_AGENT == null) {
USER_AGENT = "Sismics Reader Android " + ApplicationUtil.getVersionName(context) + "/Android " + Build.VERSION.RELEASE + "/" + Build.MODEL;
client.setUserAgent(USER_AGENT);
}
if (ACCEPT_LANGUAGE == null) {
Locale locale = Locale.getDefault();
ACCEPT_LANGUAGE = locale.getLanguage() + "_" + locale.getCountry();
client.addHeader("Accept-Language", ACCEPT_LANGUAGE);
}
}