> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notifly.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Customize Android notifications with an interceptor

> Modify a notification before the Notifly Android SDK displays it.

Register a notification interceptor after initializing the Notifly Android SDK. The interceptor can adjust how a notification looks or behaves before the SDK displays it.

```kotlin theme={null}
package com.your.project

import android.app.Application
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import tech.notifly.Notifly
import tech.notifly.push.interfaces.INotificationInterceptor
import tech.notifly.push.interfaces.IPushNotification

class SampleApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        // Initialize Notifly SDK
        Notifly.initialize(
            context = applicationContext,
            projectId = BuildConfig.NOTIFLY_PROJECT_ID,
            username = BuildConfig.NOTIFLY_USERNAME,
            // Use a placeholder for legacy compatibility. Keep account passwords and API Secret Keys out of the app.
            password = BuildConfig.NOTIFLY_USERNAME,
        )

        // Add Notifly notification interceptor
        Notifly.addNotificationInterceptor(object : INotificationInterceptor {
            override fun postBuild(
                builder: NotificationCompat.Builder,
                notification: IPushNotification
            ): NotificationCompat.Builder {
                // Customize the notification here
                builder.setColor(ContextCompat.getColor(applicationContext, R.color.purple_700))
                // You can add more customizations based on your requirements
                return builder
            }
        })
    }
}
```

## Interceptor interface

Implement `postBuild` in `INotificationInterceptor`. It receives two arguments.

* `builder: NotificationCompat.Builder`. Modify this builder to change how the notification looks or behaves.
* `notification: IPushNotification`. Use its notification data to decide which changes to apply.

Return the modified builder from `postBuild`.

> [!NOTE]
>
> On Android 8.0 (API level 26) and later, notification channel settings take precedence. For example, a sound set on the channel can override `builder.setSound()`. Check the notification channel when changing these settings.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.