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


Java CookieManager.setAcceptCookie方法代码示例

本文整理汇总了Java中android.webkit.CookieManager.setAcceptCookie方法的典型用法代码示例。如果您正苦于以下问题:Java CookieManager.setAcceptCookie方法的具体用法?Java CookieManager.setAcceptCookie怎么用?Java CookieManager.setAcceptCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.CookieManager的用法示例。


在下文中一共展示了CookieManager.setAcceptCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCookieFromAppCookieManager

import android.webkit.CookieManager; //导入方法依赖的package包/类
public static String getCookieFromAppCookieManager(String url) throws MalformedURLException {
    CookieManager cookieManager = CookieManager.getInstance();
    if (cookieManager == null)
        return null;
    // 出錯點 1
    cookieManager.setAcceptCookie(true);
    String rawCookieHeader = null;
    URL parsedURL = new URL(url);

    // 出錯點 2
    // Extract Set-Cookie header value from Android app CookieManager for this URL
    rawCookieHeader = cookieManager.getCookie(parsedURL.getHost());
    if (rawCookieHeader == null)
        return null;
    return rawCookieHeader;
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:17,代码来源:Connector.java

示例2: setCookie

import android.webkit.CookieManager; //导入方法依赖的package包/类
private void setCookie(Context context, String domain, String sessionCookie) {
    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    if (sessionCookie != null) {
        // delete old cookies
        cookieManager.removeSessionCookie();
    }
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    cookieManager.setCookie(domain, sessionCookie);

    CookieSyncManager.createInstance(context);
    CookieSyncManager.getInstance().sync();
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:19,代码来源:BaseWebView.java

示例3: initializeWebView

import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void initializeWebView() {
    _centerWebView = ((Activity) _context).findViewById(R.id.centerWebView);
    _centerWebView.getSettings().setBuiltInZoomControls(true);
    _centerWebView.getSettings().setSupportZoom(true);
    _centerWebView.getSettings().setJavaScriptEnabled(true);
    _centerWebView.getSettings().setLoadWithOverviewMode(true);
    _centerWebView.setWebViewClient(new WebViewClient());
    _centerWebView.setWebChromeClient(new WebChromeClient());
    _centerWebView.setInitialScale(100);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(false);
    _centerWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            _loadingUrl = false;
        }
    });
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:19,代码来源:CenterViewController.java

示例4: sendResponseMessage

import android.webkit.CookieManager; //导入方法依赖的package包/类
protected void sendResponseMessage(HttpResponse response) {
    super.sendResponseMessage(response);
    Header[] headers = response.getHeaders("Set-Cookie");
    if (headers != null && headers.length > 0) {
        CookieSyncManager.createInstance(this.val$context).sync();
        CookieManager instance = CookieManager.getInstance();
        instance.setAcceptCookie(true);
        instance.removeSessionCookie();
        String mm = "";
        for (Header header : headers) {
            String[] split = header.toString().split("Set-Cookie:");
            EALogger.i("正式登录", "split[1]===>" + split[1]);
            instance.setCookie(Constants.THIRDLOGIN, split[1]);
            int index = split[1].indexOf(";");
            if (TextUtils.isEmpty(mm)) {
                mm = split[1].substring(index + 1);
                EALogger.i("正式登录", "mm===>" + mm);
            }
        }
        EALogger.i("正式登录", "split[1222]===>COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
        instance.setCookie(Constants.THIRDLOGIN, "COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
        instance.setCookie(Constants.THIRDLOGIN, "COOKIE_APP_ID=" + LemallPlatform.getInstance().getmAppInfo().getId() + ";" + mm);
        CookieSyncManager.getInstance().sync();
        this.val$iLetvBrideg.reLoadWebUrl();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:HttpTask.java

示例5: a

import android.webkit.CookieManager; //导入方法依赖的package包/类
public static void a(Context context, String str, String str2, String str3, String str4) {
    if (!TextUtils.isEmpty(str)) {
        CookieSyncManager.createInstance(context);
        CookieManager instance = CookieManager.getInstance();
        instance.setAcceptCookie(true);
        String str5 = null;
        if (Uri.parse(str).getHost().toLowerCase().endsWith(".qq.com")) {
            str5 = ".qq.com";
        }
        instance.setCookie(str, b("logintype", "MOBILEQ", str5));
        instance.setCookie(str, b("qopenid", str2, str5));
        instance.setCookie(str, b("qaccesstoken", str3, str5));
        instance.setCookie(str, b("openappid", str4, str5));
        CookieSyncManager.getInstance().sync();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:a.java

示例6: loadUrl

import android.webkit.CookieManager; //导入方法依赖的package包/类
public void loadUrl(final String url)
{
    if (mOverrideTitle)
    {
        mContext.setTitle(url);
    }
    CookieManager cookieManager = CookieManager.getInstance();
    Log.e("AUTHTOKEN", cookieManager.getCookie("https://stackexchange.com"));

    Map<String, String> abc = new HashMap<>();
    abc.put("Set-Cookie", cookieManager.getCookie("https://stackexchange.com"));

    mWebView.loadUrl(url, abc);

    cookieManager.setAcceptCookie(true);
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:17,代码来源:CustomWebView.java

示例7: clearCookie

import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void clearCookie() {
    CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getContext());
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    cookieManager.removeSessionCookie();
    cookieManager.removeAllCookie();
    cookieSyncManager.sync();
}
 
开发者ID:TakWolf,项目名称:CNode-OAuth-Login-Android,代码行数:10,代码来源:CNodeOAuthLoginView.java

示例8: setCookies

import android.webkit.CookieManager; //导入方法依赖的package包/类
/**
 * 给webview设置cookie
 *
 * @param context
 * @param url
 */
public static void setCookies(Context context, String url) {
    if (!TextUtils.isEmpty(url)) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
            CookieSyncManager.createInstance( context);
        }
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeSessionCookie();
        // 自动注入cookie,这个在使用cookie作为用户校验时有用
        cookieManager.setCookie(url, "JSESSIONID=" + QuickUtil.getToken());
        CookieSyncManager.getInstance().sync();
    }
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:20,代码来源:QuickUtil.java

示例9: DisplayTemperatureDialog

import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public void DisplayTemperatureDialog(@NonNull String url) {
    final Dialog dialog = createDialog();
    dialog.setContentView(R.layout.dialog_webview);

    TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
    titleView.setText("Temperature Graph");

    com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(v -> dialog.dismiss());

    if (!url.startsWith("http://") && !url.startsWith("https://")) {
        url = "http://" + url;
    }

    WebView webview = dialog.findViewById(R.id.dialog_webview);

    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setBuiltInZoomControls(true);
    webview.getSettings().setSupportZoom(true);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.setWebViewClient(new WebViewClient());
    webview.setInitialScale(100);

    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(false);

    webview.loadUrl(url);

    displayDialog(dialog);
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:33,代码来源:DialogController.java

示例10: deleteCookie

import android.webkit.CookieManager; //导入方法依赖的package包/类
public void deleteCookie() {
    CookieSyncManager.createInstance(this.context).sync();
    CookieManager instance = CookieManager.getInstance();
    instance.setAcceptCookie(true);
    instance.removeAllCookie();
    LemallPlatform.getInstance().setCookieLinkdata("");
    System.gc();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:LogonManager.java

示例11: setGameTokenCookie

import android.webkit.CookieManager; //导入方法依赖的package包/类
public static void setGameTokenCookie(Context context, String token) {
    CookieSyncManager syncManger = CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    cookieManager.setCookie("http://api.game.letvstore.com", "sso_tk=" + token);
    syncManger.sync();
    LogInfo.log("wlx", "game cookie =  " + cookieManager.getCookie("http://api.game.letvstore.com"));
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:SyncUserStateUtil.java

示例12: setCookies

import android.webkit.CookieManager; //导入方法依赖的package包/类
public static void setCookies(Context context, String url) {
    String cookie1 = "letvclient_sig=" + MD5.toMd5(Global.DEVICEID + LetvConstant.MIYUE_ATTENDANCE);
    String cookie2 = "letvclient_did=" + Global.DEVICEID;
    CookieSyncManager syncManger = CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    String CookieStr = cookieManager.getCookie(url);
    if (CookieStr == null || !CookieStr.contains("letvclient_did") || !CookieStr.contains("letvclient_sig")) {
        cookieManager.setAcceptCookie(true);
        cookieManager.setCookie(url, cookie1);
        cookieManager.setCookie(url, cookie2);
        syncManger.sync();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:LetvUtils.java

示例13: get_location

import android.webkit.CookieManager; //导入方法依赖的package包/类
public void get_location(){
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
      if(ASWP_LOCATION) {
	//Checking for location permissions
	if (Build.VERSION.SDK_INT >= 23 && !check_permission(1)) {
		ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, loc_perm);
		show_notification(2, 2);

          } else {
              GPSTrack gps;
              gps = new GPSTrack(MainActivity.this);
              double latitude = gps.getLatitude();
              double longitude = gps.getLongitude();
              if (gps.canGetLocation()) {
                  if (latitude != 0 || longitude != 0) {
                      cookieManager.setCookie(ASWV_URL, "lat=" + latitude);
                      cookieManager.setCookie(ASWV_URL, "long=" + longitude);
                      //Log.w("New Updated Location:", latitude + "," + longitude);  //enable to test dummy latitude and longitude
                  } else {
                      Log.w("New Updated Location:", "NULL");
                  }
              } else {
                  show_notification(1, 1);
                  Log.w("New Updated Location:", "FAIL");
              }
          }
      }
  }
 
开发者ID:mgks,项目名称:Android-SmartWebView,代码行数:30,代码来源:MainActivity.java

示例14: onReceive

import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_screenEnableReceiver onReceive");

    _screenEnabled = true;

    _centerTextView = ((Activity) _context).findViewById(R.id.centerTextView);

    _centerWebView = ((Activity) _context).findViewById(R.id.centerWebView);
    _centerWebView.getSettings().setBuiltInZoomControls(true);
    _centerWebView.getSettings().setSupportZoom(true);
    _centerWebView.getSettings().setJavaScriptEnabled(true);
    _centerWebView.getSettings().setLoadWithOverviewMode(true);
    _centerWebView.setWebViewClient(new WebViewClient());
    _centerWebView.setWebChromeClient(new WebChromeClient());
    _centerWebView.setInitialScale(100);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(false);
    _centerWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            _progressDialog.dismiss();
            _loadingUrl = false;
        }
    });

    _youTubePlayerView = ((Activity) _context).findViewById(R.id.centerYoutubePlayer);
    if (Keys.YOUTUBE_API_KEY.length() != 0) {
        _youTubePlayerView.initialize(Keys.YOUTUBE_API_KEY, CenterViewController.this);
    } else {
        _logger.Warn("Please enter your youtube api key!");
        Toasty.error(_context, "Please enter your youtube api key!", Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-MediaServer,代码行数:35,代码来源:CenterViewController.java

示例15: handleMessage

import android.webkit.CookieManager; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
    PortalFragment fragment = mActivityRef.get();
    if (fragment == null) {
        return;
    }
    WebView webview = (WebView) fragmentView
            .findViewById(R.id.webview);
    switch (msg.what) {
        case BaseRunnable.REFRESH:
            java.net.CookieStore rawCookieStore = ((java.net.CookieManager)
                    CookieHandler.getDefault()).getCookieStore();
            if (rawCookieStore != null) {
                CookieManager cookieManager = CookieManager.getInstance();
                cookieManager.setAcceptCookie(true);
                try {
                    URI uri = new URI(PORTAL_URL);
                    for (HttpCookie cookie : rawCookieStore.get(uri)) {
                        String cookieString = cookie.getName() + "="
                                + cookie.getValue() + "; domain="
                                + cookie.getDomain();
                        cookieManager.setCookie(PORTAL_URL + "myPortal.do",
                                cookieString);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            webview.loadUrl(PORTAL_URL + "aptreeList.do");
            break;
        case BaseRunnable.ERROR:
            webview.loadUrl(PORTAL_URL);
            break;
    }
    fragment.dismissProgressDialog();
    Toast.makeText(fragment.getContext(), R.string.web_back_hint, Toast.LENGTH_SHORT)
            .show();
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:39,代码来源:PortalFragment.java


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