Android Question Please Clarify This? A Background Activity with a MediaPlayer Stream!

FierceBlaze

Member
Licensed User
I just returned to B4A to recreate an app that I was only able to build in B4A before. But this Background/Foreground Activity vs Android 8+ issue has me nuts on this forum... I can't seem to get a straight answer. Can someone please lay this to rest for me? I just need to play a mediaplayer or exo stream from a background activity. Can someone post a sample of what that would look like nowadays?

I looked at some helpful stuff at these links but I can't string it together. All I can tell anyone is that STICKY is bad now.
https://www.b4x.com/android/forum/threads/reduce-volume-of-mp3-player-in-the-background.51158/
https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546/
https://www.b4x.com/android/forum/t...-music-when-incoming-calls.84325/#post-534349

I think I can figure out the Notifications Builder stuff from
https://www.b4x.com/android/forum/threads/nb6-notifications-builder-class-2018.91819/
 

npsonic

Active Member
Licensed User
I'm not sure how Starter service behave with older B4A versions, but with 8.50 it stays background as long as user terminates it.

You can easily add player to Starter and control it from activity or maybe create a some widget for it.

Check this thread about services
https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546/#content

Update: Starting from B4A v8.3 the starter service will never be killed unless the whole process is killed. This means that you can always assume in your code that the starter service is running.
It is done internally by changing the starter service context to the application context.
 

FierceBlaze

Member
Licensed User
Thank you. I saw that same line and jumped to that same conclusion earlier. I just wasn't sure if it would be the best place to do it. I'll try it and make a follow up.
 
Top