2013-04-02 63 views
1

我正在通過GCM服務向Android設備發送通知。將消息傳遞給客戶端不是問題,因爲在手機上收到通知時沒有聲音播放,這是問題所在。使用GCM服務的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。

回答

0

,如果你要玩自定義通知聲音

notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3"); 
0

添加此行的代碼功能激活的默認通知聲音添加此。

notification.Defaults = NotificationDefaults.Sound; 
相關問題