Search code examples
androidservicepush-notification

Play a sound loop when push notification arrived


I have following problem: I search a soluten where i can play a sound loop when a push notification arrived. The sound should play every 5 secounds until the user brings the app into focus again.

Whats the best and reliable way to do this? It should have the lowest possible latency.

Should i use Services? The used android versions goes from 5 - 11 (all coded in Java, Push notifications comes from Pushy not FCM)

Thanks for any reply :)


Solution

  • You'd better use Android's AlarmManager

    According to the documentation:

    AlarmManager provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future.

    You can learn more about it here.