Android WebView - 1st LoadData() works fine, subsequent calls do not update display

Jim picture Jim · Nov 4, 2010 · Viewed 11.4k times · Source

After the 1st call to LoadData() the event onLoadResource fires as it should and the display is fine. Next I want to refresh the screen with a new page, when I use LoadData() the second time the page does not update and onLoadResource() DOES NOT FIRE.

Then second call to LoadData() onlyfires onPageFinished ... onPageStarted never fires!

A work around was to call .reload() after LoadData() but that causes all sorts of problems during the other logic in the activity.

Why doesn't LoadData() work multiple times?

I am using extremely simple HTML, and since using .reload() makes it work my LoadData() statement doesn't seem to be the problem.

Any Ideas would be helpful, TIA

Answer

xtera picture xtera · Jan 28, 2011

Use

webview.loadDataWithBaseURL("same://ur/l/tat/does/not/work", "data", "text/html", "utf-8", null);

it works fine. loaddata does not refresh next time the data is loaded.