'Android webview with timer

I am implementing a timer on webview activity with 1 second delay like clock. On each event webview is loaded with generated HTML having canvas and 2 tables. With each tick, webview regenerate html and display content. As soon as I start scroll to go down, it starts scrolling auto and behaves erratically and moves up and down. Thanks in advance for your help



Solution 1:[1]

Thanks for your knowledge sharing. This issue was solved after 5 days by following countermeasures:

  1. Splitting html into different divs and script tags.

  2. Replacing full html mWebView.loadDataWithBaseURL with
    String updateScript += "var mydiv=document.getElementById('div1');"; updateScript += "var oldScript=document.getElementsByTagName('script')[0];"; updateScript += "var newScript = document.createElement('script');"; updateScript += "mydiv.innerHTML= textStr;"; updateScript += "newScript.innerHTML = scrStr;"; updateScript += "document.body.appendChild(newScript);"; updateScript += "oldScript.remove();";

mWebView.loadurl("javascript:" + updateScript); on handler event.

Thanks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1