Start SubscriberService as background service

This commit is contained in:
Jonathan Klee 2024-09-04 16:59:36 +02:00
parent 31eadd9768
commit 5aceba6474
2 changed files with 1 additions and 12 deletions

View file

@ -88,17 +88,6 @@ class SubscriberService : Service() {
Log.init(this) // Init logs in all entry points Log.init(this) // Init logs in all entry points
Log.d(TAG, "Subscriber service has been created") Log.d(TAG, "Subscriber service has been created")
val title = getString(R.string.channel_subscriber_notification_title)
val text = if (BuildConfig.FIREBASE_AVAILABLE) {
getString(R.string.channel_subscriber_notification_instant_text)
} else {
getString(R.string.channel_subscriber_notification_noinstant_text)
}
notificationManager = createNotificationChannel()
serviceNotification = createNotification(title, text)
startForeground(NOTIFICATION_SERVICE_ID, serviceNotification)
} }
override fun onDestroy() { override fun onDestroy() {

View file

@ -55,7 +55,7 @@ class SubscriberServiceManager(private val context: Context) {
Log.d(TAG, "ServiceStartWorker: Starting foreground service with action $action (work ID: ${id})") Log.d(TAG, "ServiceStartWorker: Starting foreground service with action $action (work ID: ${id})")
Intent(context, SubscriberService::class.java).also { Intent(context, SubscriberService::class.java).also {
it.action = action.name it.action = action.name
ContextCompat.startForegroundService(context, it) context.startService(it)
} }
} }
return Result.success() return Result.success()