Android WebView performance

后端 未结 4 1250
春和景丽
春和景丽 2020-12-08 05:32

In my app, I am loading a list of external url\'s in webview and allow user to flip through them. Webviews are loaded on to a view flipper. I find the performance is reall

4条回答
  •  被撕碎了的回忆
    2020-12-08 06:14

    This has already been discussed here: Enhance webView performance (should be the same performance as native Web Browser)

    I ran into a similar issue, and after some heavy debugging noticed the native browser and WebView browser seem to be using different caches.

    This code can be used to disable the WebView cache, and made WebView much faster for me (though at the expense of not caching). Note that it uses private APIs, so by using it you're risking the code will break in future releases:

    try
    {
      Method m = CacheManager.class.getDeclaredMethod("setCacheDisabled", boolean.class);
      m.setAccessible(true);
      m.invoke(null, true);
    }
    catch (Throwable e)
    {
      Log.i("myapp","Reflection failed", e);
    }
    

提交回复
热议问题