当前位置: 首页>>代码示例>>Java>>正文


Java PersistentCookieStore.getCookies方法代码示例

本文整理汇总了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;
}
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:22,代码来源:MyImageDownloader.java

示例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();

}
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:17,代码来源:Global.java

示例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();
    }

}
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:31,代码来源:AttachmentsDownloadDetailActivity.java

示例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();
        }
    }
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:32,代码来源:FileDownloadBaseActivity.java

示例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;
}
 
开发者ID:sismics,项目名称:books,代码行数:16,代码来源:PreferenceUtil.java


注:本文中的com.loopj.android.http.PersistentCookieStore.getCookies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。