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

时间:2017-02-13 11:29:01

标签: android xamarin.forms portable-class-library

我正在使用 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);

1 个答案:

答案 0 :(得分:0)

您可以使用默认通知声音,如下所示:

  .SetDefaults(NotificationDefaults.Sound)