繁体   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