LibreTube/app/src/main/java/com/github/libretube/MyApp.kt

39 lines
1.1 KiB
Kotlin
Raw Normal View History

2022-02-01 21:22:06 +05:30
package com.github.libretube
2021-12-14 21:45:53 +05:30
import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
2021-12-14 21:45:53 +05:30
2022-06-05 15:12:33 +05:30
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)
}
}
2021-12-14 21:45:53 +05:30
companion object {
@JvmField
var seekTo: Long? = 0
2021-12-14 21:45:53 +05:30
}
}