简体   繁体   中英

Preloading the Webview in Activity A and Passing it to Activity B for faster loading

in one of my app i am using webview to load the pages, the scenario is i have Activity A and Activity B, Activity A displays the menu list, on selection of any of the item in the list it will open Activity B, in Activity BI am doing all the webview related activities like loading webview using the URL but its taking lot of time to display that page, my question here is there anyway i can preload the webview in activity A and pass it to B for immediate loading.

if it's possible to preload the webview in Activity A and pass it to Activity B for immediate rendering please let me know how it is doable?

Note : I can use progress dialog in Activity A until the webview loads(wait till onPageFinished) get called and start the Activity B, but how can i make the webview load immediately here?

You cant share of transfer views between activities in any way. So you should stay within single activity (you can use fragments to organize your views). Create webview, hide it, start loading data. Show webview when data is loaded.

PS You can manually download html source code and/or some resources to use with webview later... but this can be tricky.

您无法在活动之间共享视图,但根据您从网址加载的页面类型,您可以将html缓存到SD卡上的文件中,然后从此文件中加载活动B中的WebView。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM