简体   繁体   中英

Xamarin.forms How to play an android notification sound

I am using Xaminn.Forms PLC project, right now I am trying to set sound for notification on android project, I add the notification to my project using:

assembly: Xamarin.Forms.Dependency (typeof (NotificationService))]

on the following my code used to display the notification:

   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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM