本文整理汇总了Java中com.loopj.android.http.PersistentCookieStore.getCookies方法的典型用法代码示例。如果您正苦于以下问题:Java PersistentCookieStore.getCookies方法的具体用法?Java PersistentCookieStore.getCookies怎么用?Java PersistentCookieStore.getCookies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.loopj.android.http.PersistentCookieStore
的用法示例。
在下文中一共展示了PersistentCookieStore.getCookies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: download
import com.loopj.android.http.PersistentCookieStore; //导入方法依赖的package包/类
private void download(String url) {
try {
mFile = FileUtil.getDestinationInExternalPublicDir(getFileDownloadPath(), mFileObject.getSaveName(mProjectObjectId));
PersistentCookieStore cookieStore = new PersistentCookieStore(AttachmentsDownloadDetailActivity.this);
String cookieString = "";
for (Cookie cookie : cookieStore.getCookies()) {
cookieString += cookie.getName() + "=" + cookie.getValue() + ";";
}
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.addRequestHeader("Cookie", cookieString);
request.setDestinationInExternalPublicDir(getFileDownloadPath(), mFileObject.getSaveName(mProjectObjectId));
request.setTitle(mFileObject.getName());
// request.setDescription(mFileObject.name);
// request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
request.setVisibleInDownloadsUi(false);
// request.allowScanningByMediaScanner();
// request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
// request.setShowRunningNotification(false);
downloadId = downloadManager.enqueue(request);
downloadListEditor.putLong(mFileObject.file_id, downloadId);
downloadListEditor.commit();
} catch (Exception e) {
Toast.makeText(this, R.string.no_system_download_service, Toast.LENGTH_LONG).show();
}
}
示例4: download
import com.loopj.android.http.PersistentCookieStore; //导入方法依赖的package包/类
private void download(ArrayList<AttachmentFileObject> mFileObjects) {
try {
for (AttachmentFileObject mFileObject : mFileObjects) {
final String urlDownload = Global.HOST_API + "%s/files/%s/download";
String url = String.format(urlDownload, getProjectPath(), mFileObject.file_id);
PersistentCookieStore cookieStore = new PersistentCookieStore(this);
String cookieString = "";
for (Cookie cookie : cookieStore.getCookies()) {
cookieString += cookie.getName() + "=" + cookie.getValue() + ";";
}
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.addRequestHeader("Cookie", cookieString);
request.setDestinationInExternalPublicDir(getFileDownloadPath(), mFileObject.getSaveName(getProjectId()));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
request.setTitle(mFileObject.getName());
request.setVisibleInDownloadsUi(false);
long downloadId = downloadManager.enqueue(request);
downloadListEditor.putLong(mFileObject.file_id + mFileObject.getHistory_id(), downloadId);
// backgroundUpdate(downloadId);
}
downloadListEditor.commit();
mUpdateDownloadHandler.start();
checkFileDownloadStatus();
} catch (Exception e) {
Toast.makeText(this, R.string.no_system_download_service, Toast.LENGTH_LONG).show();
}
}
示例5: getAuthToken
import com.loopj.android.http.PersistentCookieStore; //导入方法依赖的package包/类
/**
* Returns auth token cookie from shared preferences.
* @return Auth token
*/
public static String getAuthToken(Context context) {
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
List<Cookie> cookieList = cookieStore.getCookies();
for (Cookie cookie : cookieList) {
if (cookie.getName().equals("auth_token")) {
return cookie.getValue();
}
}
return null;
}