---
title: "The last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the sys"  
description: "The last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the sys"  
author: "Anonymous User"  
published: 2015-08-02  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/12746/the-last-callback-in-the-lifecycle-of-an-activity-is-ondestroy-the-system-calls-this-method-on-your-activity-as-the-final-signal-that-your-activity-instance-is-being-completely-removed-from-the-sys  
category: "android"  
tags: ["android", "android activity"]  
reading_time: 2 minutes  

---

# The last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the sys

onPause() and onStop() will not be invoked if finish() is called from within the onCreate() method. This might occur, for example, if you detect an error during onCreate() and call finish() as a result. In such a case, though, any cleanup you expected to be done in onPause() and onStop() will not be executed.\
Best practice in Android development is to have the activity perform most cleanup during onPause() and onStop(). However, if the activity includes background threads that are created during onCreate(), or other long-running resources that could potentially leak memory if not properly closed, you should kill them during onDestroy().

## Answers

### Answer by Anonymous User

onPause() and onStop() will not be invoked if finish() is called from within the onCreate() method. This might occur, for example, if you detect an error during onCreate() and call finish() as a result. In such a case, though, any cleanup you expected to be done in onPause() and onStop() will not be executed.\
Best practice in Android development is to have the activity perform most cleanup during onPause() and onStop(). However, if the activity includes background threads that are created during onCreate(), or other long-running resources that could potentially leak memory if not properly closed, you should kill them during onDestroy().


---

Original Source: https://www.mindstick.com/interview/12746/the-last-callback-in-the-lifecycle-of-an-activity-is-ondestroy-the-system-calls-this-method-on-your-activity-as-the-final-signal-that-your-activity-instance-is-being-completely-removed-from-the-sys

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
