【发布时间】:2016-08-23 17:12:56
【问题描述】:
我一直在使用在我的 Android Xamarin 应用中播放自定义声音的简单概念,但无论我尝试什么,声音都不会播放。
我在 Resources 下创建了一个“raw”文件夹,并添加了一个适当的声音文件。我已确保该文件正在构建为 Android 资源。
这是我的代码:
// note I have also tried just /raw/NotificationSound, /integeridofresource and many other formats
string sSoundUrl = "android.resource://" + AppGlobals.PackageName + "/raw/NotificationSound.wav";
Notification nNotification = new Notification.Builder(this.Activity).SetSmallIcon(Resource.Drawable.AppIcon)
.SetContentTitle("Test title")
.SetContentText("Hello notifications")
.SetAutoCancel(true)
.SetSound(Android.Net.Uri.Parse(sSoundUrl)).Build();
// I have tried 0, All, NotificationDefaults.Sound basically all different combinations
nNotification.Defaults = NotificationDefaults.Lights;
NotificationManager nmNotManager = (NotificationManager)this.Activity.GetSystemService(Context.NotificationService);
nmNotManager.Notify(0, nNotification);
我希望有人能发现我做错了什么......
谢谢!!!
【问题讨论】:
-
这段代码是否在派生自
GcmListenerService的类中?
标签: android xamarin notifications push