I\'m creating a notification with RemoteViews from a custom Service
, which is running with notification in a foreground mode (that is, service will remain activ
You would have to call NotificationManager.notify(id, notification)
to let Notification System know that you want to update the notification view. Here's the docs link http://developer.android.com/training/notify-user/managing.html.
Have a method which returns Notification object.
private Notification getNotification(NotificationCompat.Builder mBuilder) {
RemoteViews mRemoteViews = new RemoteViews(getPackageName(), R.layout.notification_layout);
// Update your RemoteViews
mBuilder.setContent(mRemoteView);
Notification mNotification = mBuilder.build();
// set mNotification.bigContentView if you want to
return mNotification;
}
private void refreshNotification() {
mNotificationManager.notify(getNotification(mNotificationBuilder),
NOTIFICATION_ID);
// mNotificationBuilder is initialized already
}
Also, note that bigContentView
and RemoteViews
are not completely redrawn. If some of the elements of bigContentView has visibility set to GONE
, and if you want to show it the next time, you have to explicitly set visibility to VISIBLE
.