Skip to content

Commit

Permalink
Android: VNCConnService: ensure startForeground() is always called
Browse files Browse the repository at this point in the history
Closes #230
  • Loading branch information
bk138 committed Oct 17, 2023
1 parent 93a4fee commit dbaf3ca
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class VNCConnService : Service() {
val manager = getSystemService(NotificationManager::class.java)
manager.createNotificationChannel(serviceChannel)
}

// call startForeground() ASAP, with empty message
startForeground(NOTIFICATION_ID, getNotification(""))
}


Expand Down Expand Up @@ -111,7 +114,7 @@ class VNCConnService : Service() {
}
}
Log.d(TAG, "onStartCommand: notifying with " + getString(R.string.connected_to, hosts))
startForeground(NOTIFICATION_ID, getNotification(getString(R.string.connected_to, hosts)))
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).notify(NOTIFICATION_ID, getNotification(getString(R.string.connected_to, hosts)))
}
// stay until explicitly stopped
return START_STICKY
Expand Down

0 comments on commit dbaf3ca

Please sign in to comment.