mytechead

Android & Wordpress Help center

Android: Enable local cookies in Phonegap webview

Have been creating Phonegap and Android hybrid app with mixed native and Phonegap specific UI components lately. Yesterday I came across a scenario where I was not able to get the cookie information. After hours of exploration found that a single missing line of code was all I needed to correctly retrieve my saved cookies. So here it goes:-

Inside your Activity which should extend CordovaActivity you should write:-

CookieManager.setAcceptFileSchemeCookies(true);

Just above the line:-

super.loadUrl(URL_TO_LOAD);

that is just before loading the webpage.

This will allow cookies to be accepted for file scheme URLs.

Hope it saves your time!
Advertisements

Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: