Updating TextView in Custom Notification Layout

I made my own layout for a foreground service with a notification (obviously) that includes some text elements.

At some point, the TextView text needs to be changed, so I use the setText method to do this. The problem is that nothing happens, it doesn't update the notification.

I've tried calling invalidate, postInvalidate, and even postInvalidateDelayed. I tried to rebuild the notification and trigger the notification, I also tried to use startForeground (same ID for both cases).

Any ideas?

+3


source to share


1 answer


I found a solution, I had to use setTextViewText on the RemoteViews notification object and then either notify / startForeground to update it.



It looks like using the setText method doesn't work, so anyone with the same problem should be aware of this.

+5


source







All Articles