Вопрос

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