Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the <a href="http://developer.android.com/reference/android/webkit/CookieSyncManager.html" rel="noreferrer">Android documentation</a>: </p> <blockquote> <p>The <code>CookieSyncManager</code> is used to synchronize the browser cookie store between RAM and permanent storage. To get the best performance, browser cookies are saved in RAM. A separate thread saves the cookies between, driven by a timer. </p> <p>To use the <code>CookieSyncManager</code>, the host application has to call the following when the application starts:</p> <pre><code>CookieSyncManager.createInstance(context) </code></pre> <p>To set up for sync, the host application has to call</p> <pre><code>CookieSyncManager.getInstance().startSync() </code></pre> <p>in Activity.onResume(), and call</p> <pre><code> CookieSyncManager.getInstance().stopSync() </code></pre> <p>in Activity.onPause().</p> <p>To get instant sync instead of waiting for the timer to trigger, the host can call</p> <pre><code>CookieSyncManager.getInstance().sync() </code></pre> <p>The sync interval is 5 minutes, so you will want to force syncs manually anyway, for instance in onPageFinished(WebView, String). Note that even sync() happens asynchronously, so don't do it just as your activity is shutting down.</p> </blockquote> <p>Finally something like this should work:</p> <pre><code>// use cookies to remember a logged in status CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); WebView webview = new WebView(this); webview.getSettings().setJavaScriptEnabled(true); setContentView(webview); webview.loadUrl([MY URL]); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload