---
title: "Activity Life Cycle in Android: Pausing and resuming an activity"  
description: "Hi Everyone, I am explaining here about the Android Activity States. Here  I come up with how an activity is paused and then resumed."  
author: "Anonymous User"  
published: 2014-11-12  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1523/activity-life-cycle-in-android-pausing-and-resuming-an-activity  
category: "android"  
tags: ["android", "android activity"]  
reading_time: 4 minutes  

---

# Activity Life Cycle in Android: Pausing and resuming an activity

This post is the [extension](https://www.mindstick.com/articles/22/extension-method) of my [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) post - [Activity Life](https://www.mindstick.com/forum/145517/can-you-explain-the-android-activity-life-cycle) Cycle in Android: [Starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) an Activity . Here we are going to discuss about Pause and resume state in Android [Life cycle](https://www.mindstick.com/articles/23194/the-life-cycle-of-software-development).

While we are running our app, sometimes the focused foreground activity is obstructed by other visual [components](https://www.mindstick.com/blog/74096/understanding-the-role-of-some-integral-ac-components) which [results](https://yourviews.mindstick.com/view/88282/boost-your-career-mindstick-technical-training-that-delivers-results) the activity to pause state. For example, when a semi-[transparent](https://answers.mindstick.com/qa/92940/which-platform-launched-for-transparent-taxation-in-2020-india) activity opens (such as one in the style of dialog), the previous activity gets paused. As long as the activity is still partially visible but currently not the activity in focus, it remains paused.

As our activity enters the paused state, the onPause() method is immediately called by system on our activity, which allow us to stop ongoing actions that should not continue while paused(such as a video) or persist any information that should be permanently saved in case the user continues to leave our app. And if the user returns to our activity from paused state, the system resumes it and calls the onResume() method

![Activity Life Cycle in Android: Pausing and resuming an activity](https://www.mindstick.com/mindstickarticle/7fcd94c7-a06c-4650-a729-4da09bbed838/images/5acc3d8d-5a80-426d-8e0a-cce4030bd57e.png)

When a semi-transparent activity obscures our activity, the system calls onPause() and the activity waits in then paused state (1). If the user returns to the activity while it’s still paused , the system calls onResume()(2)

##

##### Pause our Activity

When the system cause onPause() for our activity, its technically means our activity is still partially visible , but most often it’s an indication that the user is leaving the activity and it will soon entered the Stopped state. We should usually use the onPause() callback to :

· Stop animations and other ongoing actions that consumes CPU

· Commit unsaved changes, but only when the user expects such changes to be permanently saved when they leave (such as a draft email).

· Release system resources, such as broadcast receivers, handles to sensors etc.

For example, if our app uses the Camera, the onPause() method is good place to release it.

```
@Overridepublic void onPause(){        super.onPause(); // Call to super class method         //Release the Camera because we don’t need it when paused         //  and other activates might need to use it          if(mCamera ! = null) {              mCamera.release()              mCamera = null;
            }
}
```

1. We must not use onPause() to store user changes(such as personal information entered into a form) to permanent storage

2. We should avoid performing CPU-intensive working during onPause(), such as writing to a database, because it can slow the visible transition to next destination to the next activity

NOTE : When our activity is paused, the activity instance is kept resident in memory and is recalled when the activity resumes. We don’t need to re-initialize components that were created during any of the callbacks methods leading to Resumed state

##### Resume Our Activity

When the user come back to our activity i.e. resumes our activity from paused state, the system calls the onResume() method.

That is, system calls this method every time our activity comes into the foreground, including when it’s created for the first time. As such we should implement onResume() to initialize our components that we release during onPause() and perform any other initializations that must occurs time the activity enters the Resumed state (such as begin animation and initialize components only used while the activity has user focus).

```
@Overridepublic void onResume() {     super.onResume(); //Call the superclass method
     // Get the camera instance as the activity achieves full user focus      If(mCamera == null) {           intializeCamera(); // Local method to handle camera init
      }
}   
```

This post is referred from Google docs Pausing and Resuming an Activity

Next, we will going to see how to stop and restart an activity in Activity Lifecycle: Stopping and Restarting an Activity in Android

---

Original Source: https://www.mindstick.com/articles/1523/activity-life-cycle-in-android-pausing-and-resuming-an-activity

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
