The CookieSyncManager 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.
To use the CookieSyncManager, the host application has to call the following
when the application starts:
CookieSyncManager.createInstance(context)
To set up for sync, the host application has to call
CookieSyncManager.getInstance().startSync()
in Activity.onResume(), and call
CookieSyncManager.getInstance().stopSync()
in Activity.onPause().
To get instant sync instead of waiting for the timer to trigger, the host can
call
CookieSyncManager.getInstance().sync()
The sync interval is 5 minutes, so you will want to force syncs
manually anyway, for instance in {@link
WebViewClient#onPageFinished}. Note that even sync() happens
asynchronously, so don't do it just as your activity is shutting
down. |