简体   繁体   English

Android推送通知停止在活动恢复时重复播放声音

[英]Android push notification stop repeating sound on activity resume

I am implementing an app that receive push notifications. 我正在实现一个接收推送通知的应用程序。 I have used flag Notification.FLAG_INSISTENT to continuously play sound until user drag notification panel. 我已经使用标志Notification.FLAG_INSISTENT连续播放声音,直到用户拖动通知面板为止。 But I want to stop the sound on app resume rather than on dragging notification panel. 但是我想停止在应用履历表上而不是在通知面板上拖动声音。

According to documentation , for notifications with FLAG_INSISTENT audio will be repeated until the notification is cancelled or the notification window is opened. 根据文档 ,对于带有FLAG_INSISTENT通知,将重复音频,直到取消通知或打开通知窗口。

So when you resume your activity you can cancel your notification. 因此,当您恢复活动时,可以取消通知。 if you want it to stay in the notification window, then redisplay it again without sound and the insistent flag. 如果您希望它保留在通知窗口中,请再次重新显示它而没有声音和坚持标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM