Can we save login data in android WebView?

后端 未结 2 954
我在风中等你
我在风中等你 2021-01-03 17:19

My website needs to be logged in to use it, so is there a way to save login data for the users so they will not log in every time they enter the WebView, like f

相关标签:
2条回答
  • 2021-01-03 17:53

    I found the answer.

    We just need to add this.webView.getSettings().setDomStorageEnabled(true); along with this.webView.getSettings().setJavaScriptEnabled(true);.

    Now we can delete the cookies codes, and save data and logins.

    EDIT: If it doesn't work, try not to delete the cookies code.

    0 讨论(0)
  • 2021-01-03 17:53

    try to get values by javascript injection

    webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                webView.loadUrl(
                    "javascript:(function() { " +
                        "var element = document.getElementById('hplogo');"
                        + "element.parentNode.removeChild(element);" +
                    "})()");
            }
        });
    
    0 讨论(0)
提交回复
热议问题