当前位置 : 主页 > 手机开发 > android >

android – 异步任务的需求是什么

来源:互联网 收集:自由互联 发布时间:2021-06-11
我们必须使用异步任务来启动我们对Tab Click事件的新Activity,但是在ListView或任何视图中我们可以直接启动新活动为什么? http://developer.android.com/reference/android/os/AsyncTask.html AsyncTask enable
我们必须使用异步任务来启动我们对Tab Click事件的新Activity,但是在ListView或任何视图中我们可以直接启动新活动为什么? http://developer.android.com/reference/android/os/AsyncTask.html

AsyncTask enables proper and easy use
of the UI thread. This class allows to
perform background operations and
publish results on the UI thread
without having to manipulate threads
and/or handlers.

An asynchronous task is defined by a
computation that runs on a background
thread and whose result is published
on the UI thread.on the UI thread.

基本上,您希望避免加载进程/设备在最初将数据加载到列表时挂起,这就是为什么在UI线程之外使其异步,以便用户可以在后台加载数据时使用该应用程序.

启动活动比将大量初始数据加载到长列表视图中更快,特别是如果它是来自远程服务器的远程数据.因此,您正在查看的应用程序可能正在使用此处.

网友评论