32 lines
947 B
Kotlin
32 lines
947 B
Kotlin
package com.example.oilcheckkotlin
|
|
|
|
import android.R
|
|
import android.app.Notification
|
|
import android.app.PendingIntent
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import androidx.core.app.NotificationCompat
|
|
|
|
|
|
class NotificationCreator {
|
|
private val NOTIFICATION_ID = 1094
|
|
private val CHANNEL_ID = "Foreground Service Channel"
|
|
private var notification: Notification? = null
|
|
|
|
fun getNotification(context: Context?, intent: PendingIntent): Notification? {
|
|
if (notification == null) {
|
|
|
|
notification = NotificationCompat.Builder(context!!, CHANNEL_ID)
|
|
.setContentTitle("Oil-Check")
|
|
.setContentText("running")
|
|
.setSmallIcon(com.example.oilcheckkotlin.R.drawable.icon)
|
|
.setContentIntent(intent)
|
|
.build()
|
|
}
|
|
return notification
|
|
}
|
|
|
|
fun getNotificationId(): Int {
|
|
return NOTIFICATION_ID
|
|
}
|
|
} |