Note that there are some explanatory texts on larger screens.

plurals
  1. POWebView.getUrl() returns null
    text
    copied!<p>I have an issue with Webview. I'm programming my own WebChromeClient class overriding onProgressChanged method because I want to show the page when it finishes loading and then, to hide the splash screen. As I just want it to happen with a specific url, I compare the actual WebView url with a specific string, but there is a problem, I get a null pointer when webview.getUrl() method is called and my application finishes. This is the code:</p> <pre><code>private class MyWebChromeClient extends WebChromeClient { @Override public void onProgressChanged (WebView webview, int newProgress) { super.onProgressChanged(webview,newProgress); if(webview.equals(w1) &amp;&amp; newProgress == 100 &amp;&amp; webview.getUrl().startsWith("https://ssl.facebook.com/login.php")) { webview.setVisibility(WebView.VISIBLE); ImageView imageview = (ImageView)findViewById(R.id.ivsplash); imageview.setVisibility(ImageView.GONE); ProgressBar progressbar = (ProgressBar)findViewById(R.id.pbsplash); progressbar.setVisibility(ProgressBar.GONE); } } } </code></pre> <p>I do this for avoid the webview takes three or four seconds to render the page, but it doesn't work. The code I used before was:</p> <pre><code>private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView webview, String url) { super.shouldOverrideUrlLoading(webview, url); webview.loadUrl(url); return true; } @Override public void onPageFinished(WebView webview, String url) { if(url.startsWith("https://ssl.facebook.com/login.php")) { webview.setVisibility(WebView.VISIBLE); ImageView imageview = (ImageView)findViewById(R.id.ivsplash); imageview.setVisibility(ImageView.GONE); ProgressBar progressbar = (ProgressBar)findViewById(R.id.pbsplash); progressbar.setVisibility(ProgressBar.GONE); } } } </code></pre> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload