---
title: "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?"  
description: "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?"  
author: "Hemant Patel"  
published: 2018-01-10  
canonical: 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  
category: "technology"  
tags: ["android"]  
reading_time: 1 minute  

---

# 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](https://www.mindstick.com/articles/54917/how-to-keep-her-happy-in-a-long-distance-relationship) between the life [cycle of an AsyncTask](https://www.mindstick.com/forum/33396/what-is-the-relationship-between-the-life-cycle-of-an-asynctask-and-an-activity) and an [Activity](https://www.mindstick.com/blog/23160/fidgetsguide-exercise-guides-newsletters)? What problems can this [result](https://yourviews.mindstick.com/story/1037/cbse-class-12-result-declared-and-tanya-singh-topped-after-securing-500-500) in? How can these problems be avoided?

## Answers

### Answer by Prateek sharma

an **async task** works within the activity so the lifecycle does not come together. as async task works continuously 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 because the async task will return an instance to the older activity instance which is destroyed.

to avoid this exception user must use other option such as **service** or **sync adapter** for a long-running service.


---

Original Source: 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

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
