AsynchTask got onPostExecute() method tied to UI thread. Assume that we close an activity by pressing back button while AsynchTask doInBackground() method is still in progress.

  1. I want to know will onPostExecute executes by considering that activity is not displaying on screen anymore?
  2. In case answer is yest, will it cause exceptions or not? (because of accessing UI objects which are not longer displayed on screen).
有帮助吗?

解决方案

1-I want to know will onPostExecute executes by considering that activity is not displaying on screen anymore?

yes!

2-In case answer is yest, will it cause exceptions or not? (because of accessing UI objects which are not longer displayed on screen).

Yes! it may cause Exception because your Instance of your Activity and Views which you use in your AsyncTask are not exist anymore

This Link will help you more : AsyncTask won't stop even when the activity has destroyed

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top