![](/img/trans.png)
[英]How to play custom sound in Xamarin.Forms on Android using Local Notifications / Notification.Builder
[英]Xamarin.forms How to play an android notification sound
我正在使用Xaminn.Forms PLC項目,現在我正在嘗試在android項目上設置通知的聲音,我使用以下命令將通知添加到我的項目中:
assembly: Xamarin.Forms.Dependency (typeof (NotificationService))]
在以下我的用於顯示通知的代碼上:
var notification = new Notification.Builder (Application.Context)
.SetContentTitle (message.Short_Message.ToString ())
.SetContentText (message.Long_Message.ToString())
.SetSmallIcon (Resource.Mipmap.ic_launcher)
.SetStyle(new Notification.BigTextStyle().BigText(message.Long_Message))
.SetPriority((int)NotificationPriority.Max)
.SetContentIntent(OpenAppOnCLickOnNotificaton)
.SetLights(255,1000,1000)
.Build ();
var manager = Application.Context.GetSystemService (Application.NotificationService) as NotificationManager;
manager.Notify (message.ID, notification);
您可以按以下方式使用默認通知聲音:
.SetDefaults(NotificationDefaults.Sound)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.