gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:38:27 27 4
gpt4 key购买 nike

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

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);

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

请帮我解决问题。

谢谢

最佳答案

The flags that are used in notification builder

1.Notification.DEFAULT_SOUND:used to play sound.

2.Notification.FLAG_INSISTENT:this flag is makes your sound to ring continuously until you have done few operations on notification ie, either you drag the bar or you click the bar.

3.Notification.FLAG_AUTO_CANCEL:this flag is used to automatically cancel the notification after you have seen it

关于android - 打开通知面板时通知声音停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160952/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com