使用WebView保存登录信息

时间:2018-10-24 11:03:23

标签: android cookies webview

我搜索了很多,但是找不到解决方案,所以... 如何保存我的登录信息,这样我每次进入应用程序时都不必注册?

public class MainActivity extends AppCompatActivity {

private WebView myWebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myWebView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    myWebView.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url) {
            //This part doesn't do what 
            String cookies = CookieManager.getInstance().getCookie(url);
        }
    });

    myWebView.loadUrl("https://www.iepp.es/nuevo/");
}

}

0 个答案:

没有答案