---
title: "how to destroy an activity without going through onResume and onDestroy methods?"  
description: "how to destroy an activity without going through onResume and onDestroy methods?"  
author: "Prateek sharma"  
published: 2018-04-07  
updated: 2018-04-07  
canonical: https://answers.mindstick.com/qa/40998/how-to-destroy-an-activity-without-going-through-onresume-and-ondestroy-methods  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# how to destroy an activity without going through onResume and onDestroy methods?

\

## Answers

### Answer by Arti Mishra

## Distroy An activity without using onDestroy() & onResume method:

Actually onDestroy() method **does not destroy the activity** object, **it isn’t a destructor**. It is **simply a method** that’s called for some certain **situation or state**. If you are using onDestroy() method after that you wants to restart the App or project, it makes the starting phase faster and all the process will not be doing anything and if memory needs to be reclaimed, the whole process will be killed.

And If you want to destroy an activity without using onDestroy () & onResume () method then you can **use finish () method** for destroying an activity. In android, finish () method is used to totally destroy the current activity.

## Example:

…………………….

………………………

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

LinearLayout layout = (LinearLayout) findViewById(R.id.myLayoutId);

Button button = new Button(this);

button.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View view) {

Toast.makeText(AndroidLifecycle.this, "Calling finish() method",

Toast.LENGTH_SHORT).show ();

Log.d(TAG, "User just clicked button to destroy the current activity");

finish();

}

});

layout.addView(button);

}

..........................

...........................


---

Original Source: https://answers.mindstick.com/qa/40998/how-to-destroy-an-activity-without-going-through-onresume-and-ondestroy-methods

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
