diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 226643432..9cda3e3cc 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -100,18 +100,21 @@ class BackgroundMode : Service() { */ override fun onCreate() { super.onCreate() - if (Build.VERSION.SDK_INT >= 26) { - val channelId = BACKGROUND_CHANNEL_ID + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel( - channelId, + BACKGROUND_CHANNEL_ID, "Background Service", NotificationManager.IMPORTANCE_DEFAULT ) val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(channel) - val notification: Notification = Notification.Builder(this, channelId) + + // see https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification) + val notification: Notification = Notification.Builder(this, BACKGROUND_CHANNEL_ID) .setContentTitle(getString(R.string.app_name)) - .setContentText(getString(R.string.playingOnBackground)).build() + .setContentText(getString(R.string.playingOnBackground)) + .build() + startForeground(PLAYER_NOTIFICATION_ID, notification) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index 7af018805..5b6fb34e5 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -62,7 +62,10 @@ class SubscriptionsFragment : BaseFragment() { // listen for error responses viewModel.errorResponse.observe(viewLifecycleOwner) { - if (it) Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() + if (it) { + Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() + viewModel.errorResponse.value = false + } } viewModel.videoFeed.observe(viewLifecycleOwner) {