Closed gjedeer closed 7 years ago
I see what you mean. But there is a better solution: reuse the same notification builder, and just update the content text when the notification is updated.
Something like this:
private val notificationBuilder by lazy {
val contentIntent = PendingIntent.getActivity(service, RequestCode,
Intent(service, PlayingQueueActivity::class.java), PendingIntent.FLAG_CANCEL_CURRENT)
NotificationCompat.Builder(service)
.setContentTitle(service.getString(R.string.notification_loading_title))
.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_notification)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setProgress(0, 0, true)
}
private fun updateLoadingNotification() {
notificationBuilder
.setContentText(torrentManager.getDownloadSpeed())
service.startForeground(NotificationId, notificationBuilder.build())
handler.postDelayed(UpdateLoadingNotificationRunnable, 1000)
}
Didn't work. I also tried usng notify() instead of startForeground() with no luck:
notificationBuilder.setContentText(torrentManager.getDownloadSpeed())
notificationManager.notify(NotificationId, notificationBuilder.build())
// service.startForeground(NotificationId, notificationBuilder.build())
handler.postDelayed(UpdateLoadingNotificationRunnable, 1000)
Did you put the notificationbuilder as a class member? That definitely worked when i tried it.
hmmm that is weird.but i dont really like to remove the progressbar, cause its harder to see that its actually doing something
not sure what to do :/
I will just close this PR
Currently the notification progress bar is "flickering" which doesn't look great. I mean the effect that every time bandwidth is reported, the progress bar is set to 0. There's probably a better way than removing the progress bar altogether but I couldn't figure it out.