Ultimate Guide to Observe Application Lifecycle Events in Android

Recently, Android has provided LifecycleObserver interface to observe Application lifecycle events easily. But I have seen on Stackoverflow that few developers are still struggling in using ‘LifecycleObserver‘ interface. This tutorial will help you to understand how to listen, Application Lifecycle Events. Using ‘LifecycleObserver‘ interface we can easily receive Application Lifecycle Events in Android.

Following is the Java solution if you are looking for Kotlin solution you can visit Kotlin Tutorial.

Steps to Observe Application Lifecycle Events

1. Add the following dependency in your App-level build.gradle file.

implementation 'android.arch.lifecycle:extensions:1.1.1'

2. Create the Application Class if you don’t already have it in your project. For that create a new class with the name ‘ApplicationClass‘.

Add the following code in your Application Class.

import android.app.Application;
import android.util.Log;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ProcessLifecycleOwner;

public class ApplicationClass extends Application implements LifecycleObserver {

    public void onCreate() {

        ProcessLifecycleOwner.get().getLifecycle().addObserver(this); // to observe Application lifecycle events

    public void onAppStart() {
        Log.e("lifecycle event","ON_START");

    public void onAppResume() {
        Log.e("lifecycle event","ON_RESUME");

    public void onAppPause() {
        Log.e("lifecycle event","ON_PAUSE");

    public void onAppStop() {
        Log.e("lifecycle event","ON_STOP");

    public void onAppDestroy() {
        Log.e("lifecycle event","ON_DESTROY");


In the above code, you can remove the extra methods for the events you don’t want to receive.

For those who are using the Support Library instead of Androidx, change the above imports with the following.

import android.app.Application;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.arch.lifecycle.ProcessLifecycleOwner;
import android.util.Log;

3. Don’t forget to add Application class reference in your ‘AndroidManifest.xml‘ file, if you have created a new Application class in step 2. For that, Add the following property in your ‘application‘ tag.


That’s it. Enjoy 🙂

You can also find other useful helping articles, code snippets and tutorials in our Coding Articles & Tutorials Knowledge Base.

Please share this post:
Native Mobile Application Developer (Android + IOS) having experience in Java, Swift, Kotlin, Objective C, Unity, C#, C/C++, NODE JS & PHP.

2 thoughts on “Ultimate Guide to Observe Application Lifecycle Events in Android

  1. Very good written article. It will be supportive to everyone who utilizes it, as well as myself. Keep up the good work – can’r wait to read more posts.

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: