Search code examples
androidnotificationsandroid-viewratingbarremoteview

Use RatingBar in notification


I am developing an app in which user can give reviews and I am pushing notification to that user to whom review is posted. Now I have a requirement from client to show the rating in the notification

I have searched about it and found this solution to customize the notification but now I am not getting how to use RatingBar.


Solution

  • You cannot use android.widget.RatingBar inside notification, because it's not allowed to be used with RemoteViews mechanism. The way you determine whether a particular view is a eligible to use in notifications is checking whether that view is annotated with @RemoteView.

    For example, you can see, that TextView is annotated with @RemoteView. RatingBar is not.

    There are limited amount of views that are allowed to be used with RemoteViews mechanism. I couldn't find a list of those view in documentation, but a simple search within Android Studio will reveal all of them.

    enter image description here