mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 23:00:31 +05:30
39 lines
1.1 KiB
Kotlin
39 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
|
|
|
|
const val NOTIFICATION_ID = 1
|
|
|
|
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
|
|
}
|
|
}
|