打开通知面板时通知声音停止

Ank*_*ary 5 android android-notifications

我正在处理一个项目,但在通知中遇到了一个奇怪的问题。基本上我想在通知中播放警报,为此我在通知生成器中添加声音 ieuri。这是我的代码:

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);
Run Code Online (Sandbox Code Playgroud)

通知出现在面板中,但是当我触摸通知面板向下滚动时,音乐会自动停止。我无法理解场景。

请帮我解决问题。

谢谢

Ano*_*p M 0

通知生成器中使用的标志

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

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

3.Notification.FLAG_AUTO_CANCEL:该标志用于在看到通知后自动取消通知