VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/android-progress-notifications-in-kotlin/

⇱ Android progress notifications in Kotlin - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Android progress notifications in Kotlin

Last Updated : 12 Jul, 2025

In this tutorial you'll learn how to create a basic Progress Notification (Indeterminate progress indicator and Fixed-duration progress indicator) for Android using Kotlin. Before we begin, let us first understand the components of a Notification in Android.

Components of a Notification:

👁 Image
  1. Small Icon - Required, can be set with setSmallIcon().
  2. Application Name - Provided by the system.
  3. Time Stamp - Provided by the system but can be overridden.
  4. Large Icon - Optional, can be set with setLargeIcon().
  5. Title - Optional, can be set with setContentTitle().
  6. Text - Optional, can be set with setContentText().

Note : Since the introduction of Android version 8 (Android Oreo), it is now compulsory to categorize all the notifications into categories called Notification Channels. This is for the convenience of users and also developers. The image below shows us a notification channel named 'Progress Notification'.

👁 Image

Step by Step Implementation:

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language. Choose the API level according to your choice( Here we have chosen API Level 26).

Step 2:Adding Permission for notification

Android 13 (API level 33) and higher need a permission for posting notifications from an app. For this, declare permission in the manifest file. Please manually make sure that the permission for notifications is provided for this app on phone.

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Step 3: Working with the activity_main.xml file

Go to the activity_main.xml file and refer to the following code. We are just going to add a basic button to trigger the notification.

activity_main.xml:

Step 4: Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

MainActivity.kt:

Output:

Comment
Article Tags:

Explore