In Android 14 my notification is not updating.
When a user wants to upload a video I have this process.
1.- Start Service
2.- Shows a notification to while the app is searching for pending videos to upload
(The notification will show using startForeground function)
3.- When the app finds a video/s to upload it will update the notification to the upload notfication with a progress bar
(The notification will show using startForegroundService function because I have to start the amazon TransferService service)
Till Android 13 the notification updates and is working as intended but with Android 14 the notification is getting stuck in the first one and not updating
Code used to start searching for videos notification:
private fun showNotification(notification: NotificationCompat.Builder) {
startForeground(NOTIFICATION_ID, notification.build())
}
Code used to start the uploading notification
private fun startTransferService(notification: NotificationCompat.Builder) {
try {
tsIntent = Intent(this, TransferService::class.java)
tsIntent?.putExtra(TransferService.INTENT_KEY_NOTIFICATION, notification.build())
tsIntent?.putExtra(
TransferService.INTENT_KEY_NOTIFICATION_ID,
NOTIFICATION_ID
)
tsIntent?.putExtra(TransferService.INTENT_KEY_REMOVE_NOTIFICATION, true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(tsIntent)
} else {
startService(tsIntent)
startForeground(NOTIFICATION_ID, notification.build())
}
} catch (exc: Exception) {
if (exc is CancellationException) {
throw exc
}
stopForeground()
exc.printStackTrace()
}
}
I've noticed that if I start the uploading notification using the functions startService and startForeground instead of startForegroundService it will update the notification and it will work as intended but these function should be used in previous versions than Oreo if I'm not wrong