【问题标题】:Xamarin.forms How to play an android notification soundXamarin.forms 如何播放 android 通知声音
【发布时间】:2017-02-13 11:29:00
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    您可以使用以下默认通知声音:

      .SetDefaults(NotificationDefaults.Sound)
    

    【讨论】:

    • 工作正常,但如何设置自定义通知声音?
    • 嗨,我已经尝试使用上面的线路来获得声音但不是运气。请提出我所缺少的。
    猜你喜欢
    • 2012-01-14
    • 2016-03-19
    • 2012-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    相关资源
    最近更新 更多