向Xamarin.Android中的通知添加声音

问题描述 投票:1回答:1

我通过此链接创建了一个通知: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”。我该如何解决?

c# android xamarin xamarin.android notifications
1个回答
1
投票

您可以使用以下行进行转换。

© www.soinside.com 2019 - 2024. All rights reserved.