WebView - Part 4 Handling Cookies in WebView

Posted by muamar Sabtu, 21 Mei 2011 0 komentar

Handling Cookies in WebView

Actually this is very simple, as we mentioned in Part 1 of this series, that for security reasons, your application will have its own cache and its own cookie store i.e. it doesn’t share the Browser’s application data, cookies are also managed in separate thread which means that those operations which are for managing cookies (e.g. building index) will not block your application’s UI thread.

Now, we use “android.webkit.CookieSyncManager” class to manage cookies particularly to synchronize the browser cookies between RAM and permanent storage. To get maximum efficiency cookies are stored in RAM and a separate thread is used to save cookies this thread is driven by timer, sync interval is of 5 Minutes.

To use CookieSyncManager all you have to do is add these three lines in your code
Call this when the application starts.
 
CookieSyncManager.createInstance(context);
 
To set up sync call in Activity.onResume()
 
CookieSyncManager.getInstance().startSync();
 
and lastly, call this in Activity.onPause()
 
CookieSyncManager.getInstance().stopSync();
 
To get sync instantly without waiting for the timer to trigger, host can call
 
CookieSyncManager.getInstance().sync();
 
But be aware that this sync also happens asynchronously, so don’t do it just as your activity is shutting down.

<<WebView - Part 3 How to customize WebView?




Cheers!!
Vivek Jain
Hello Everyone, I came across an application which allowed me to produce nice effects on Images that are in my phone and Images that I take from my phones camera, its available here, 
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: WebView - Part 4 Handling Cookies in WebView
Ditulis oleh muamar
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke http://androidlist4.blogspot.com/2011/05/webview-part-4-handling-cookies-in.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android list.