prom85
prom85

Reputation: 17788

Start android service immediately

I have an app with an integrated music player. This player plays music in a service...

Now my app is a sports app, so the user listens to music and sometimes, timer events occur and play a alarm sound. I want to use the service for playing these sound because I want to stop the normal music, play the alarm and resume the music.

My problem is, sometimes (not very often), there is a quite long delay... Of some seconds...

How can I avoid this?

Btw., I implemented a Do-Not-Disturb Mode, so I can't use audio focus if this mode is enabled. I have to manually pause the player only for internal alarms and resume afterwards...

Upvotes: 0

Views: 458

Answers (1)

Alessandro Roaro
Alessandro Roaro

Reputation: 4733

You could start the Service at the boot, and then simply bind to it whenever you need it. Checkout the docs to learn how a Service works.

Upvotes: 1

Related Questions