1

我正在通过 GCM 服务向 android 设备发送通知。向客户端传递消息不是问题,因为在电话上收到通知时没有播放声音,这是问题所在。

我在客户端(mono android)上使用以下代码来建立通知请求

void createNotification(string title, string desc)
     {
       //Create notification
       var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

    //Create an intent to show ui
    var uiIntent = new Intent(this, typeof(Main));

    //Create the notification
    var notification = new Notification(Android.Resource.Drawable.SymActionEmail, title);

    //Auto cancel will remove the notification once the user touches it
    notification.Flags = NotificationFlags.AutoCancel;

    //Set the notification info
    //we use the pending intent, passing our ui intent over which will get called
    //when the notification is tapped.
    notification.SetLatestEventInfo(this, title, desc, PendingIntent.GetActivity(this, 0, uiIntent, 0));

    //Show the notification
    notificationManager.Notify(1, notification);
}

在这里我可以在哪里放置要播放的通知声音的详细信息?我已经尝试过 Notification.Sound 成员,但它要求我没有参考的 uri。

4

2 回答 2

0

如果您想播放自定义通知声音,请添加此项

  notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
于 2013-04-02T06:10:04.390 回答
0

在函数中添加这行代码激活默认通知声音。

notification.Defaults = NotificationDefaults.Sound;
于 2013-04-02T21:16:01.210 回答