【发布时间】:2019-10-02 13:32:13
【问题描述】:
我在此链接后创建了一个通知:https://docs.microsoft.com/it-it/xamarin/android/app-fundamentals/notifications/local-notifications
//Create notification channel:
` CreateNotificationChannel():
instance.CreateNotificationChannel("enter","On_Enter");
//Build notification
var builder = new NotificationCompat.Builder(instance,"enter")
.SetSmallIcon(global::Android.Resource.Drawable.IcDialogInfo)
.SetContentTitle("Proximity") // Set the title
.SetContentText($"benvenuto nel beacon di colore {deskOwner}, {description}")
.SetDefaults(NotificationDefaults.Sound)
.Build();
// Get the notification manager:
NotificationManager notificationManager = instance.GetSystemService(Context.NotificationService) as NotificationManager;
// Pubblico la notifica:
const int notificationId = 0;
notificationManager.Notify(notificationId, builder);
return null;
}
当我编写 SetDefaults 将声音添加到通知中时,我会报错: 这是错误: 无法从“Android.App.NotificationDefaults”转换为“int”。 我该如何解决?
【问题讨论】:
-
您可以尝试将 NotificationDefaults.Sound 转换为 int 或使用 Notification.Builder(已弃用)。
标签: c# android xamarin xamarin.android notifications