Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我调用intent.stopActivity(),并且在该 Activity 内部,我在实例化时调用了 AsyncTask:在停止 Activity 时任务是否被取消,还是会保留在后台?
intent.stopActivity()
我不知道 中的stopActivity方法Intent,但是AsyncTask当它的调用Activity被“停止”时,无论是真正处于停止状态还是完成,都不会自动取消。如果您希望发生这种情况,请在 like 中调用cancel适当的AsyncTask生命周期方法。ActivityonStop
stopActivity
Intent
AsyncTask
Activity
cancel
onStop