0

I need to save user login credentials for WebView in Android.

I have tried this, but with no luck.

    WebView mWebview  = (WebView) v.findViewById(R.id.wv_spielplan);

    if(BuildConfig.VERSION_CODE < 21){
        CookieManager.getInstance().setAcceptCookie(true);
    } else {
        CookieManager.getInstance().setAcceptThirdPartyCookies(mWebview, true);
    }
    CookieSyncManager.createInstance(getActivity());
    CookieSyncManager.getInstance().startSync();
Zookey
  • 2,637
  • 13
  • 46
  • 80

1 Answers1

1

If the webview displays internet content, you may want to deal with the data from server side. Online or if you are showing "off line" assets content, i.e., content packaged with your app, allow javascript and DOM to work and you will be able to set a cookie inside webview. Edit: have a look at this: https://stackoverflow.com/a/5409155/5885018 and Set a cookie to a webView in Android

Community
  • 1
  • 1
statosdotcom
  • 3,109
  • 2
  • 17
  • 40
  • I am loading URL from Internet and they told me that they have cookies and that I need just enable and save cookies so users can stay logged in Web view . Is that possible? – Zookey Feb 15 '16 at 20:31