RuudJ
RuudJ

Reputation: 63

Spotify Android SDK with Doze battery optimizations

When I use the Spotify Android SDK to play music and Doze kicks in, the music stops playing because the app loses network connectivity. Is there a way to solve this?

The only way I can think of is ask the user to whitelist the app using a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent. But I read that a lot of developers get their app banned from the play store when doing that.

Upvotes: 1

Views: 299

Answers (1)

RuudJ
RuudJ

Reputation: 63

Running the Spotify instance in a foreground service fixes the problem. See https://developer.android.com/guide/topics/media/mediaplayer.html#foregroundserv

Upvotes: 1

Related Questions