Search code examples
androiduser-interfacenotificationsalarmmanagerremoteview

Notification size when not showing first


I'm using local notification like clock alarm with buttons to control it. My problem is that the Notification view isn't wrapping my content. So after searching around I found out that there is a workaround to achieve this by setting the view after build.
Something like this:

Notification notification = mBuilder.build();
// add remote view after build for getting bigger notification size
notification.bigContentView = remoteViews;

This work unless the notification is not first and when it is not the top notification the buttons is not shown.

How can I make the notification wrap_content even when it is not the top on the list of notifications?


Solution

  • Set the priority Max for notification for showing big content view like below

       new Notification.Builder(this)
        .setContentTitle("Media Player")
        .setContentIntent(mPendingIntentHomeSong)
        .setSmallIcon(R.drawable.app_icon)
        .setPriority(Notification.PRIORITY_MAX)
        .setContent(mNotificationContentView)
        .setStyle(new Notification.BigPictureStyle()).build();