Webview saveState does not handle custom WebViewClient

Scale

You must handle orientation changes for WebView.

Problem

saveState / restoreState does not work for WebView when using a custom WebViewClient (a blank page is displayed).

Code snippet

setContentView(R.layout.webview); // load OAuth url in WebView mWebView = (WebView) findViewById(R.id.webview); if (savedInstanceState == null) { mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new SimpleWebViewClient()); mWebView.loadUrl(Consts.URL_AUTHORIZATION_OAUTH); } else { mWebView.restoreState(savedInstanceState); } 

PS

Commenting mWebView.setWebViewClient (new SimpleWebViewClient ()); helps, but I have to use my SimpleWebViewClient, which wathces for onPageFinished during the OAuth process.

+4
source share

Source: https://habr.com/ru/post/1380392/


All Articles