Ninoo
Ninoo

Reputation: 25

How do i keep same song playing in all activities

i'm creating an android application and i need to keep one song playing even if i went to another Activity. Help me please, thank you so much!

Upvotes: 0

Views: 37

Answers (2)

Isaac Urbina
Isaac Urbina

Reputation: 1313

Use a service, but it has to be a foreground service so that it has the highest priority so that it doesn't lag nor is killed by the system on low memory, follow this example: https://www.dev2qa.com/android-foreground-service-example/

Upvotes: 1

Gastón Saillén
Gastón Saillén

Reputation: 13129

You can do it in two ways, using the singleton pattern or using a background service (recommended)

Upvotes: 0

Related Questions