當前位置: 首頁>>代碼示例>>Java>>正文


Java CookieManager.getInstance方法代碼示例

本文整理匯總了Java中android.webkit.CookieManager.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieManager.getInstance方法的具體用法?Java CookieManager.getInstance怎麽用?Java CookieManager.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.CookieManager的用法示例。


在下文中一共展示了CookieManager.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reset

import android.webkit.CookieManager; //導入方法依賴的package包/類
public void reset() {
	Editor editor = mSharedPref.edit();
	
	editor.putString(ACCESS_TOKEN, 	"");
	editor.putString(USERID, 		"");
	editor.putString(USERNAME, 		"");
	editor.putString(FULLNAME, 		"");
	editor.putString(PROFILPIC, 	"");
	editor.putInt(FOLLOW,0);
	editor.putInt(FOLLOWED,0);
	
	editor.commit();
	
	CookieSyncManager.createInstance(mContext);
	
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.removeAllCookie();
}
 
開發者ID:inceleb,項目名稱:InstagramManager-Android,代碼行數:19,代碼來源:InstagramSession.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: 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(LemallPlatform.getInstance().getContext()).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.GUESTLOGIN, split[1]);
            int index = split[1].indexOf(";");
            if (TextUtils.isEmpty(mm)) {
                mm = split[1].substring(index + 1);
                EALogger.i("正式登錄", "mm===>" + mm);
            }
        }
        EALogger.i("遊客登錄", "split[11]===>COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
        instance.setCookie(Constants.GUESTLOGIN, "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

示例4: onCreate

import android.webkit.CookieManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //清除cookie
    CookieSyncManager.createInstance(WebViewActivity.this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    setContentView(R.layout.activity_webview);

    mWebView = (WebView) findViewById(R.id.login_webview);

    mIntent = getIntent();
    mUrl = mIntent.getStringExtra("extr_url");

    mProgress = (ProgressBar) findViewById(R.id.login_webview_progress);

    init();
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:20,代碼來源:WebViewActivity.java

示例5: 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

示例6: removeExpiredCookies

import android.webkit.CookieManager; //導入方法依賴的package包/類
/**
 * 清除過期的cookie
 */
public static void removeExpiredCookies() {
    CookieManager mCookieManager = null;
    if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
        mCookieManager.removeExpiredCookie();
        toSyncCookies();
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:11,代碼來源:CookiesHandler.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: updateCookiePreference

import android.webkit.CookieManager; //導入方法依賴的package包/類
@Override
public void updateCookiePreference() {
	mCookieManager = CookieManager.getInstance();
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		CookieSyncManager.createInstance(this);
	}

	mCookieManager.setAcceptCookie(PreferenceManager.getInstance().getCookiesEnabled());
	super.updateCookiePreference();

}
 
開發者ID:Louis19910615,項目名稱:youkes_browser,代碼行數:12,代碼來源:BrowserMainActivity.java

示例9: saveUserSessionId

import android.webkit.CookieManager; //導入方法依賴的package包/類
public void saveUserSessionId(String userSessionId){
    // save to cookie manager
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setCookie(CMBCHINA_BASIC_URL, "userSessionId=" +userSessionId);
    CookieSyncManager.getInstance().sync();
    // save to sharedpreference
    SharedPreferenceHelper.getInstance(getApplicationContext()).saveString(CMBCHINA_SHARED_PERFERENCE_KEY_USER_SESSION_ID,userSessionId);
}
 
開發者ID:MarcusMa,項目名稱:MyCreditCardDemo,代碼行數:9,代碼來源:CmbChinaLoginActivity.java

示例10: 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

示例11: SystemCookieManager

import android.webkit.CookieManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SystemCookieManager(WebView webview) {
    webView = webview;
    cookieManager = CookieManager.getInstance();

    //REALLY? Nobody has seen this UNTIL NOW?
    cookieManager.setAcceptFileSchemeCookies(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.setAcceptThirdPartyCookies(webView, true);
    }
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:13,代碼來源:SystemCookieManager.java

示例12: 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

示例13: syncCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void syncCookie(String url, String cookies) {

        CookieManager mCookieManager = CookieManager.getInstance();
        if (mCookieManager != null) {
            mCookieManager.setCookie(url, cookies);
            toSyncCookies();
        }
    }
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:9,代碼來源:AgentWebConfig.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: clearCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
public void clearCookie() {

		CookieSyncManager.createInstance(this);
		CookieManager cookieManager = CookieManager.getInstance();

		cookieManager.removeAllCookie();
		CookieSyncManager.getInstance().sync();
	}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:9,代碼來源:BaseActivity.java


注:本文中的android.webkit.CookieManager.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。