ConnectSDK / Connect-SDK-Android

Android source project for Connect SDK
Apache License 2.0
308 stars 129 forks source link

Background start not allowed #419

Open petergoczan opened 2 weeks ago

petergoczan commented 2 weeks ago

Hi Everyone, I'm integrating the Fling SDK for both controller and receiver sides for my media player application. When the TV application is in the background (after a force stop) and I start casting from mobile, I'm getting the following error: Background start not allowed: service Intent { flg=0x10000000 cmp=my.package.name/my.package.fling.FlingPlayerService } to my.package.name/my.package.fling.FlingPlayerService from pid=16210 uid=10058 pkg=com.amazon.whisperlink.core.android startFg?=false

I've added these permissions to my manifest for TV: <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

And also this: `

    <service
        android:name=".fling.FlingPlayerService"
        android:exported="true"
        android:foregroundServiceType="mediaPlayback" />

    <meta-data
        android:name="whisperplay"
        android:resource="@xml/whisperplay" />`

Also, I'm starting the FlingPlayerService as a foregroundService. This issue is happening under the hood and I don't know what else I could do about it. When the TV app is opened and closed (but I assume is still in the memory), it gets opened when I'm starting the casting.

Please help 🙏