2015-07-01 56 views
1

我正在处理一个项目,并且在通知中遇到了一个奇怪的问题。 基本上我想在通知中播放警报,为此我在通知生成器中添加声音eguri。 这里是我的代码:通知声音在打开通知面板时停止

builder.setSmallIcon(R.mipmap.app_icon).setContentTitle(title) 
      .setContentText(msg) 
      .setColor(getResources().getColor(R.color.white)) 
      .addAction(R.drawable.alarm_off, getString(R.string.dismiss), pendingIntent) 
      .setOngoing(true) 
      .setSound(Uri.parse(path)); 

    Notification notification = builder.build(); 
    notification.flags |= Notification.FLAG_INSISTENT; 


    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    notificationManager.notify(WAKE_UP_ALARM_ID, notification); 

通知出现在面板,但是当我摸到通知面板向下滚动,音乐自动停止。 我无法理解这种情况。

请帮我解决问题。

感谢

+2

是android系统 –

+0

的默认行为,但是当警报在Android机器人扮演棒棒糖它的连续播放。 –

+0

以及我不知道什么发生了警报,但我很确定警报不通知,即使在文档FLAG_INSISTENT在文档中,你会发现,当用户打开通知菜单的声音将停止 –

回答

0

了在通知Builder中使用的标志

1.Notification.DEFAULT_SOUND:用于播放声音。

2.Notification.FLAG_INSISTENT:该标志使您的声音持续鸣响,直到您对通知进行了一​​些操作,即 或者您拖动栏或单击栏。

3.Notification.FLAG_AUTO_CANCEL:这个标志是用来自动取消通知你已经看到后

+1

您想说什么? –

+0

你究竟想要什么? U想要播放通知声音,直到用户轻扫或触摸通知栏为止? –

+1

不是通知栏。当用户点击我们的通知操作按钮时,它应该停止。 –