I want to implement a persistent notification that displays some text, and the text changes every few seconds. But, to conserve resources, the text should only change when it is visible on the screen. For example, when the OS top status bar is pulled down revealing all notifications, or when the lock screen is shown (for non-private notifications). How can we detect these conditions to know to update the notification text?
Asked
Active
Viewed 27 times
1 Answers
0
It doesn't seem possible.
notificationManager.notify(
ONGOING_NOTIFICATION_ID,
notificationBuilder.apply { setContentText(it) }.build()
)
I don't think that updating a notification is expensive; it is essentially just updating the content text field. When the notification becomes visible, it will perform the necessary UI calculations (I don't know for sure, but that would make sense).

BPDev
- 397
- 1
- 9