Reputation: 26
So i'm learning to use the BigTextStyle for notifications in xamarin android. For some reason whenever I run my code the bigText and SetSummaryText aren't appearing in the notification. Anyone know why? My code is below:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Notification.Builder builder = new Notification.Builder(this)
.SetContentTitle("Big Text")
.SetSmallIcon(Resource.Drawable.Icon);
Notification.BigTextStyle textStyle = new Notification.BigTextStyle();
string longTextMessage = "I went up on one pair of stairs.";
longTextMessage += " / Just like me. ";
textStyle.BigText(longTextMessage);
textStyle.SetSummaryText("The summary text goes here. ");
builder.SetStyle(textStyle);
Notification notification = builder.Build();
NotificationManager notificationManager =
GetSystemService(Context.NotificationService) as NotificationManager;
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);
}
Upvotes: 0
Views: 2322
Reputation: 74154
var notification = new Notification.Builder(Application.Context)
.SetSmallIcon(Resource.Mipmap.Icon)
.SetLargeIcon(BitmapFactory.DecodeResource(Application.Context.Resources, Resource.Mipmap.Icon))
.SetAutoCancel(true)
.SetStyle(new Notification
.BigTextStyle()
.SetSummaryText("Summary Text")
.SetBigContentTitle("Content Title")
.BigText("Big Text Area")
)
.Build();
var notificationManager = (NotificationManager)Application.Context.GetSystemService(Context.NotificationService);
notificationManager.Notify(1, notification);
Upvotes: 3