Muhammad Umar Muhammad Umar - 20 days ago 12
Java Question

WebView showing blank white page instead of loading a link

I am trying to open following link in my WebView

http://issuu.com/muhammadumar88/docs/prime_guide_2016?e=27032292/40838888

With code

mWebView = (WebView) view.findViewById(webView);
mWebView.getSettings().setJavaScriptEnabled(true);

mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
WebSettings websettings = mWebView.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setDomStorageEnabled(true);
websettings.setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.2; C1905 Build/15.1.C.2.8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36");

mWebView.setWebViewClient(new AppWebViewClient((ProgressBar) view.findViewById(R.id.progressBar)));
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl(link);



public class AppWebViewClient extends WebViewClient
{
private ProgressBar progressBar;

public AppWebViewClient(ProgressBar progressBar)
{
this.progressBar = progressBar;
progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}

@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
}


I keep on getting a white blank page. How can i fix it, what am i missing?

Answer

change the following line.

 mWebView = (WebView) view.findViewById(R.id.webView);

instead of

mWebView = (WebView) view.findViewById(webView);

For More information please Refer Webview shows white blank page