Last active
August 25, 2020 04:30
-
-
Save vreamer/979b929a72e3c12785f9b9a8b29b8dd3 to your computer and use it in GitHub Desktop.
Create Notification Channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.direct_reply_notification | |
| import android.app.NotificationChannel | |
| import android.app.NotificationManager | |
| import android.content.Context | |
| import android.graphics.Color | |
| import android.os.Build | |
| import androidx.core.app.NotificationManagerCompat | |
| object NotificationHelper { | |
| private const val CHANNEL_ID = "01" | |
| private const val CHANNEL_NAME = "Ideas" | |
| fun createChannel(context: Context) { | |
| val manager = NotificationManagerCompat.from(context) | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // check if build version is later than Android 8.0 (Oreo, API level 26) | |
| val importance = NotificationManager.IMPORTANCE_DEFAULT | |
| val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance) | |
| channel.description = "It's a personal channel" | |
| channel.enableVibration(false) | |
| channel.enableLights(true) | |
| channel.lightColor = Color.RED | |
| manager.createNotificationChannel(channel) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment