# What is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?

URL: https://answers.mindstick.com/qa/32781/what-is-the-relationship-between-the-life-cycle-of-an-asynctask-and-an-activity-what-problems-can-this-result-in-how-can-these-problems-be-avoided

What is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?

## Answers

### Answer by Prateek sharma

an async task works within the activity so the lifecycleand does not come together. as async task works continuouslyand for a period of time until it completes the process it is doing. so if the app does any activity which destroys the instance of the activity the app may make an exception becauseand the async task will return an instance to the older activity instance which is destroyed.and to avoid this exception user must use other option such as service or sync adapterand for a long-running service.

