Update TextView in Custom Notification Layout

1.3k views Asked by At

I made a custom layout for a foreground service with notification (obviously) that includes some TextViews.

At some point the TextView's text needs to be changed, so I've been using setText method to do so. The problem is: nothing happens, it doesn't update the notification.

I tried to call invalidate, postInvalidate, and even postInvalidateDelayed. I tried to rebuild the notification and call notify, I also tried to use startForeground (same ID for both cases).

Any ideas?

1

There are 1 answers

0
user3705007 On BEST ANSWER

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

It seems that just using setText method does not work, so anyone who is having the same issue, keep that in mind.