3

I am writing an Android app cotaining a webview, which loads a page including a rather large form. I show a progress bar during the loading of the form. When the progress bar disappears, I often see only a blank page or some few elements of the form (like few of the checkboxes, no text). After I try to scroll the page (click), everything shows up. Any idea of what's wrong here?

The settings of the webview are:

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setAppCacheMaxSize(1024*1024*128);
mWebView.getSettings().setAppCachePath(getActivity().getApplicationContext().getCacheDir().getAbsolutePath());
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setAppCacheEnabled(true);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
mWebView.setWebChromeClient(new WebChromeClient() {
       @Override
       public void onExceededDatabaseQuota(String url,
                            String databaseIdentifier,
                            long currentQuota,
                            long estimatedSize,
                            long totalUsedQuota,
                            WebStorage.QuotaUpdater quotaUpdater)
       {
           quotaUpdater.updateQuota(estimatedSize * 2);
       }
    });
mWebView.addJavascriptInterface(new WebFormJavascriptInterface(), "jsinterface");
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);

and the layout file is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hardwareAccelerated="false"
    android:persistentDrawingCache="all"
/>
<ProgressBar
    android:id="@+id/progressbar"
    style="@android:style/Widget.Holo.ProgressBar.Large"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:indeterminate="true"
    android:visibility="gone"/>
</RelativeLayout>
omoling
  • 151
  • 7
  • Try removing or commenting settings one by one to find which line is responsible. My bet is one of the cache lines – znat Dec 04 '12 at 12:06

3 Answers3

2

I'm having a different issue but encountered this. Doing

webview.postInvalidateDelayed(1500);

in onPageFinished() pretty much helped the WebView refresh itself after 1.5 seconds within the new WebViewClient(){} declaration. There's probably a better answer than this one, though

Masoud Mokhtari
  • 2,390
  • 1
  • 17
  • 45
Joe Plante
  • 6,308
  • 2
  • 30
  • 23
1

Do you override WebViewClient? I have same problem when override onPageStarted() and onPageFinished() methods of WebViewClient, with removing super.onPageStarted() and super.onPageFinished(). WebView load blank page first and show content when i touch screen. Return calls methods of super (super.onPageStarted(), super.onPageFinished()) resolving my problem.

Olegvarmy
  • 199
  • 1
  • 1
  • 8
1

I had a similar issue. Calling mWebView.requestFocusFromTouch() when I wanted to see the new content in the webview solved my issue.