Hello,
Welcome to our Microsoft Q&A platform!
If you want to custom the Notification UI, you can call the function of NotificationCompat.Builder
to achieve it.For example, you can use NotificationCompact.BigPictureStyle
to set a big picture notification.
You can refer to the following code:
var valuesForActivity = new Bundle();
valuesForActivity.PutInt(COUNT_KEY, count3);
// When the user clicks the notification, SecondActivity will start up.
var resultIntent = new Intent(this, typeof(PicNotificationActivity));
// Pass some values to SecondActivity:
resultIntent.PutExtras(valuesForActivity);
// Construct a back stack for cross-task navigation:
var stackBuilder = TaskStackBuilder.Create(this);
stackBuilder.AddParentStack(Class.FromType(typeof(PicNotificationActivity)));
stackBuilder.AddNextIntent(resultIntent);
// Create the PendingIntent with the back stack:
var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
// Build the notification:
var builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it
.SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
.SetContentTitle("Button3 Clicked") // Set the title
.SetSmallIcon(Resource.Drawable.logo) // This is the icon to display
.SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.pic1))
.SetContentText($"The button has been clicked {count3} times."); // the message to display.
// Instantiate the Big Text style:
//Notification.BigTextStyle textStyle = new Notification.BigTextStyle();
builder.SetVisibility(NotificationCompact.VisibilitySecret);
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
builder.SetCategory(NotificationCompact.CategoryCall);
}
// Instantiate the Image (Big Picture) style:
NotificationCompact.BigPictureStyle picStyle = new NotificationCompact.BigPictureStyle();
// Convert the image to a bitmap before passing it into the style:
picStyle.BigPicture(BitmapFactory.DecodeResource(Resources, Resource.Drawable.pic1));
// Set the summary text that will appear with the image:
picStyle.SetSummaryText("The summary text goes here.");
// Plug this style into the builder:
builder.SetStyle(picStyle);
// Finally, publish the notification:
var notificationManager = NotificationManagerCompat.From(this);
notificationManager.Notify(NOTIFICATION_ID3, builder.Build());
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.