简体   繁体   中英

Loading a Browser Page in the Background

I have a tabbed interface (one activity per tab) where one tab will be a browser view displaying a webpage. The application loads in a different activity / view, but I want it to begin to download the webpage in the background as soon as the app launches, before the user ever clicks on that tab and initiates that activity.

How can I do this?

Thanks!

-S

为什么不将页面下载到文件中,然后在下载完成后立即显示该文件呢?

I think I have a good sense of how to go about this now, although I haven't worked through the details of implementation yet.

The basic process will include:

  • In my initialization activity, call an AsyncTask to run the HTTP request in a separate thread from the primary UI thread (to ensure UI responsiveness).
  • Store the results of the HTTP request in a simple String object that is a member of my Application object (technically a subclass of Application) to provide application-wide access to the data.
  • Display the previously downloaded String data in a WebView object, using either WebView.loadData() or WebView.loadDataWithBaseUrl()

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