Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android webview displaying blank page

I have an android application that I am developing using the emulator running on android 2.3.3 with an embedded WebView in a framelayout nested in a linearlayout (vertical). No matter what code I use it never actually does anything. I have Permissions on the android application set to INTERNET. Even when trying to load just the HTML code. I get a blank white page, no errors no nothing. Nothing in logcat as well.

WebView wview = (WebView)findViewById(R.id.webView1);
wview.getSettings().setJavaScriptEnabled(true);

I have tried all three of these to attempt to load anything into the webview:

wview.loadUrl("http://www.google.com");
wview.loadData("<HTML><BODY><H3>Test</H3></BODY></HTML>","text/html","utf-8");
wview.loadDataWithBaseURL(null, "<HTML><BODY><H3>Test</H3></BODY></HTML>","text/html","utf-8",null);

All three give me the same results. Nothing.

Any ideas?

like image 280
Chris White Avatar asked Jan 13 '13 04:01

Chris White


2 Answers

WebSettings settings = wbView.getSettings();
settings.setDomStorageEnabled(true);
like image 178
zionpi Avatar answered Oct 22 '22 06:10

zionpi


It might be a bit too late, but I wanted to share my experience with you, because I had the same problem and spent a lot of time on it.

Put your WebView in RelativeLayout and not in FrameLayout.

What I have tested: My WebView's onPageFinished() was called every time, but on the screen I got blank page.

From chrome://inspect WebView debugger I was able to "ping" my WebView by pressing inspect button, and after that WebView was refreshing immediately.

My thoughts - WebView isn't rendered correctly in FrameLayout, and RelativeLayout fixes the issue (even invalidate() and requestLayout() calls didn't help).

like image 14
Veaceslav Gaidarji Avatar answered Oct 22 '22 07:10

Veaceslav Gaidarji