Notification
This commit is contained in:
+1
-17
@@ -1,22 +1,15 @@
|
||||
package com.kouros.navigation.car
|
||||
|
||||
import android.content.Intent
|
||||
import android.location.Location
|
||||
import android.os.Message
|
||||
import android.util.Log
|
||||
import androidx.car.app.CarContext
|
||||
import androidx.car.app.hardware.CarHardwareManager
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.kouros.navigation.data.Constants.TAG
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class NotificationManager(
|
||||
class NavigationNotificationManager(
|
||||
private val carContext: CarContext,
|
||||
private val lifecycleOwner: LifecycleOwner,
|
||||
) {
|
||||
|
||||
private var notificationServiceStarted = false
|
||||
@@ -24,17 +17,8 @@ class NotificationManager(
|
||||
private var serviceStarted = false
|
||||
|
||||
init {
|
||||
lifecycleOwner.lifecycleScope.launch {
|
||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
|
||||
}
|
||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.DESTROYED) {
|
||||
if (notificationServiceStarted) {
|
||||
stopNotificationService()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun startNotificationService() {
|
||||
val intent = Intent(carContext, NavigationNotificationService::class.java)
|
||||
@@ -111,7 +111,7 @@ class NavigationNotificationService : Service() {
|
||||
* Initializes the notifications, if needed.
|
||||
*
|
||||
*
|
||||
* [NotificationManager.IMPORTANCE_HIGH] is needed to show the alerts on top of the car
|
||||
* [NavigationNotificationManager.IMPORTANCE_HIGH] is needed to show the alerts on top of the car
|
||||
* screen. However, the rail widget at the bottom of the screen will show regardless of the
|
||||
* importance setting.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user