Java – preload WebView in activity a and pass it to activity B to speed up loading

In one of my applications, I use WebView to load the page. The scenario is that I have activity a and activity B. activity a displays the menu list. When selecting any item in the list, it will open activity B. in the activity, Bi is doing all activities related to WebView, such as loading WebView using URL, but it takes a lot of time to display the page. That's my problem, Anyway, I can preload WebView in activity a and pass it to B to load it immediately

If you can preload WebView in activity a and pass it to activity B for immediate rendering, tell me how it works?

Note: I can use the progress dialog box in activity a until WebView loading (wait until onpagefinished) is called and activity B is started, but how do I load WebView here immediately?

Solution

You cannot share transfer views between activities in any way Therefore, you should keep a single activity (you can use fragments to organize your view) Create a WebView, hide it, and start loading data Display WebView. When loading data

PS: you can manually download the HTML source code and / or some resources for WebView later... But this can be tricky

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>