Manage back navigation from notification in android

Milan Vadhel
2 min readJan 28, 2022
Image source from https://www.pocket-lint.com/

Hello folks, as we know navigation is a key thing in any mobile app. While developing the mobile app you must preserve the user’s expected navigation experience. Without proper navigation, users might exit from your app which creates a huge bad impact on any business-related software.

There are many entry points in your app to increase engagement from where users can start to engage with your app. Like from any weblink user can come to your app (deep link), Push notification, etc. So when whether they come from notification or weblink in your app they expect proper back navigation. So the question is how to preserve the back navigation of your app when users click on the notification and come to the specific screen?

To solve your problem, we will discuss here how we can preserve navigation.

Before starting, I am sure that you know how to create notification and notification channels (For Android 8 and above versions). So we not covering that thing here.

Step 1: Create notification and channel

Step 2: Define your app’s hierarchy in your AndroidManifest.xml file

Step 3: Create PendingIntent with your app’s back stack

Boom you are done with all required implementation.
For a complete sample, you can follow this Github repository.

Thanks for reading the article I am sure it will help you.

--

--