有人可以解释startActivity(意向)和startActivityForResult(意向)如何异步? [英] Can someone please explain how startActivity(intent) and startActivityForResult(intent) are Asynchronous?

查看:999
本文介绍了有人可以解释startActivity(意向)和startActivityForResult(意向)如何异步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个异步线程是线程分别操作以主线程,并且不与主线程干扰..

If an Asynchronous thread is a thread that operates separately to the main thread and doesn't interfere with the main thread..

有没有一个新的活动不占用主线程后,它已经通过 startActivity开始(意向)

Does a new Activity not occupy the main thread after it has been started through startActivity(intent)?

大多数我所阅读本说,这些都是异步的,但有一个公平的几个相互矛盾的答案,并且说这个真的不给予令人信服的论据的人。

The majority of what I have read on this says these are both asynchronous, however there are a fair few conflicting answers and the people that say this don't really give convincing arguments.

因此​​,如果任何人谁拥有这清楚他们的头和可以解释为什么他们是同步/异步,我将是一个非常感激的人!

So if anyone who has this clear in their head and could explain why they are synchronous/asynchronous, I would be a very grateful man!

干杯

编辑:所以我从这两个很好的人,有些东西在网上得到的答案。

So the answer I have derived from these two good folk and some stuff online..

瞻活动分为同步/异步的组合可导致马的负载来的。但它仍然是参照的原理..

Bringing Activities into the mix of synchronous/asynchronous can cause a load of horse to come about. But it is still referring to the principles of..

同步方法/命令之前必须完成的调用堆栈可以继续。

Synchronous methods/commands must be completed before the call stack can continue.

异步方法/命令(通常在一个线程中完成/ AsyncTask的)继续允许执行主线程继续。 (它可以在它自己的时间返回)

Asynchronous methods/commands (commonly done in a thread/AsyncTask) continue in parallel allowing the main thread of execution to continue. (It can return in it's own time)

在startActivity(意向)和startActivityForResult(意向)方法是异步,因为它们是不可阻挡和允许执行的线程同时继续执行其相应的任务也是如此。

The startActivity(intent) and startActivityForResult(intent) methods are Asynchronous as they are non blocking and allow the thread of execution to continue whilst performing their corresponding task as well.

推荐答案

startActivity(意向)和startActivityForResult(意向)是异步的,即这些方法立即返回。但他们也安排了活动启动当前活动的生命周期事件结束后。外卖是,如果你有需要的时候,新的活动将是缓慢的,开始你的第一个活动的东西的onPause()。

startActivity(intent) and startActivityForResult(intent) are Asynchronous in the sense that these methods return immediately. But they also schedule an activity to start after the lifecycle events of the current activity is finished. The takeaway is, if you have something in onPause() of your first activity that takes time, the new activity will be slow to start.

这篇关于有人可以解释startActivity(意向)和startActivityForResult(意向)如何异步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆