簡體   English   中英

Xamarin.forms如何播放Android通知聲音

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM