简体   繁体   English

在后台加载浏览器页面

[英]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 -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). 在我的初始化活动中,调用AsyncTask在与主UI线程不同的线程中运行HTTP请求(以确保UI响应性)。
  • 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. 将HTTP请求的结果存储在一个简单的String对象中,该对象是我的Application对象(技术上是Application的子类)的成员,以提供应用程序范围的数据访问。
  • Display the previously downloaded String data in a WebView object, using either WebView.loadData() or WebView.loadDataWithBaseUrl() 显示在web视图对象先前下载的字符串数据,即使用WebView.loadData()WebView.loadDataWithBaseUrl()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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