'Android: How do I repeat a notification sound until the notification is opened?

I am currently working on an Android App, that needs to alarm the user in case of an emergency. When the app needs to alert, it notifies the user with a heads-up notification and plays a loud sound. My problem is that I can't get the sound to repeat itself after it ends. I basically want it to loop until the users opens the notification.

I've tried to use Notification.FLAG_INSISTENT in both notification.flags and audioAttributes.setFlags(...) (inside of notificationChannel.setSound(audio, audioAttributes)), however this doesn't work.

Thanks ^^



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source