Search in sources :

Example 6 with CookieManager

use of android.webkit.CookieManager in project robolectric by robolectric.

the class ShadowCookieManagerTest method shouldRecordAcceptCookie.

@Test
public void shouldRecordAcceptCookie() {
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setCookie("foo", "bar");
    cookieManager.setCookie("baz", "qux");
    assertThat(cookieManager.getCookie("foo")).isNotNull();
    cookieManager.removeAllCookie();
    assertThat(cookieManager.getCookie("foo")).isNull();
    assertThat(cookieManager.getCookie("baz")).isNull();
}
Also used : CookieManager(android.webkit.CookieManager) Test(org.junit.Test)

Example 7 with CookieManager

use of android.webkit.CookieManager in project robolectric by robolectric.

the class ShadowCookieManagerTest method shouldNotGetCookieForHostNotInDomain.

@Test
public void shouldNotGetCookieForHostNotInDomain() {
    CookieManager cookieManager = CookieManager.getInstance();
    String value1 = "my cookie";
    cookieManager.setCookie("bar.foo.com/this%20is%20a%20test", value1);
    assertThat(cookieManager.getCookie(".bar.com")).isNull();
}
Also used : CookieManager(android.webkit.CookieManager) Test(org.junit.Test)

Example 8 with CookieManager

use of android.webkit.CookieManager in project robolectric by robolectric.

the class ShadowCookieManagerTest method shouldGetCookieForHostInSubDomain.

@Test
public void shouldGetCookieForHostInSubDomain() {
    CookieManager cookieManager = CookieManager.getInstance();
    String value1 = "my cookie";
    cookieManager.setCookie("host.in.subdomain.bar.com", value1);
    assertThat(cookieManager.getCookie(".bar.com")).isEqualTo(value1);
}
Also used : CookieManager(android.webkit.CookieManager) Test(org.junit.Test)

Example 9 with CookieManager

use of android.webkit.CookieManager in project Notes by lguipeng.

the class EvernoteUtil method removeAllCookiesV21.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void removeAllCookiesV21() {
    final CookieManager cookieManager = CookieManager.getInstance();
    Looper looper = Looper.myLooper();
    boolean prepared = false;
    if (looper == null) {
        Looper.prepare();
        prepared = true;
    }
    // requires a looper
    cookieManager.removeAllCookies(new ValueCallback<Boolean>() {

        @Override
        public void onReceiveValue(Boolean value) {
            Thread thread = new Thread() {

                @Override
                public void run() {
                    // is synchronous, run in background
                    cookieManager.flush();
                }
            };
            thread.start();
        }
    });
    if (prepared) {
        looper = Looper.myLooper();
        if (looper != null) {
            looper.quit();
        }
    }
}
Also used : Looper(android.os.Looper) CookieManager(android.webkit.CookieManager) TargetApi(android.annotation.TargetApi)

Example 10 with CookieManager

use of android.webkit.CookieManager in project AndroidTwitter by lorensiuswlt.

the class TwitterDialog method setUpWebView.

@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView() {
    CookieSyncManager.createInstance(getContext());
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    mWebView = new WebView(getContext());
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setHorizontalScrollBarEnabled(false);
    mWebView.setWebViewClient(new TwitterWebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl(mUrl);
    mWebView.setLayoutParams(FILL);
    mContent.addView(mWebView);
}
Also used : WebView(android.webkit.WebView) CookieManager(android.webkit.CookieManager) SuppressLint(android.annotation.SuppressLint)

Aggregations

CookieManager (android.webkit.CookieManager)36 CookieSyncManager (android.webkit.CookieSyncManager)9 Test (org.junit.Test)7 WebView (android.webkit.WebView)4 SuppressLint (android.annotation.SuppressLint)3 WebSettings (android.webkit.WebSettings)3 Context (android.content.Context)2 Intent (android.content.Intent)2 Editor (android.content.SharedPreferences.Editor)2 Uri (android.net.Uri)2 View (android.view.View)2 WebViewClient (android.webkit.WebViewClient)2 TextView (android.widget.TextView)2 TargetApi (android.annotation.TargetApi)1 ActionBar (android.app.ActionBar)1 AlarmManager (android.app.AlarmManager)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1