English 中文(简体)
AsyncTask对活动流动的怀疑
原标题:AsyncTask doubts regarding the activities flow

I got some concerns about AsyncTask that I could not clarify when reading the documentation.

我的主要活动是,当阿松奇·塔克创立时,我就进行了几次活动。 这些AsyncTask主要下载数据或从亚洲开发银行检索数据。

  1. If I go to a different Activity, will the AsyncTask s created on this one continue executing? Or will they stop working and leave the task half done? If so, will they go on somehow when getting back to this activity?
  2. In order to start one of the activities from the one that is running the AsyncTask s, I need one of the AsyncTask s to be fully executed. How do I set this constraint? Could you show me some sample code of this, please?

Thanks

最佳回答

如果我去做一项不同的活动,那么,阿辛克党创建的这个机构是否会继续实施? 或者他们是否停止工作并离开一半任务? 如果是的话,他们在重新开展这项活动时是否会走一些路?

是的,它将继续运作。 这可能是一把双edge剑的bit脚石,因为它通常也会被搁置到活动场上,使其生活在其<条码>的Destroy(的背后,这是不理想的。 如果你的工作没有与活动本身相同的生命周期需求,那么,可以更好地将其安置到一个服务部门。

为了从阿辛克·塔克斯开展的一项活动开始,我需要阿辛克·塔克人之一得到充分执行。 我如何确定这一制约因素? 您能否向我介绍一下这方面的一些样本。

这样做的方法太多,许多取决于您申请的结构,可以提供具体的样本......但这里是几个更高的层次想法。 * E/CN.6/2009/1。 任务执行完成时,任务提供主线上的简单反馈方法(onPostExecute),届时你可以树立旗帜。 或者,也许只是检查了A AsyncTask正在从发起活动的任何法典中提取的任何数据。 该处还将为此提供良好环境,因为多项活动可以与服务挂钩,并在向前迈进前检查任务状况。

另一种选择,视你的申请而定,是把任务的结果放在内容提供者身上。 内容提供人包括一个冰箱,向观察者通报变化,而不求助于全球广播公司。

HTH

问题回答

在使用斜体和广播接收器之前,我做了类似的事情。

如果你在完成使命时能够发出全球或全方位的意向,那么,如果你适当构造,就很容易让接收者接手。 在你把新活动推向 st子时,如果某项活动暂停,就会有接收人,因此,总是会随心 gr,并被告知(例如:数据从 d中下载)和就此采取行动。

如果你尝试和开始一项需要数据的活动,那么,如果意图尚未确定,你就可以否认开展这种活动,或者创造这种活动,如果在数据完成下载时,它就设置了一条进展节点或某种内容,那么,在达到这一目的时,其接收人就会采取行动。

希望这一帮助。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签