LibreTube/app/src/main/java/com/github/libretube/myApp.kt
Relwi f345b142aa
Configurate the notification
It stills need more work, but for now I think is fine.
2022-05-26 21:38:25 +02:00

37 lines
1.1 KiB
Kotlin

package com.github.libretube
import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
class myApp : Application() {
override fun onCreate() {
super.onCreate()
initializeNotificationChannels()
}
/**
* Initializes the required [NotificationChannel] for the app.
*/
private fun initializeNotificationChannels() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create the NotificationChannel
val name = "Background Mode"
val descriptionText = "Shows a notification with buttons to control the audio player"
val importance = NotificationManager.IMPORTANCE_LOW
val mChannel = NotificationChannel("background_mode", name, importance)
mChannel.description = descriptionText
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(mChannel)
}
}
companion object {
@JvmField
var seekTo: Long? = 0
}
}