Webradio App: Doesn't work in Background

Hello,

I am working in a Streaming App (for a Webradio), and i am having a problem with the Exo Player: When we block the phone, after some minutes, the sound stop, and it ocour even some notification of other app arrives or i press the button to check the smartphone.

Any one know’s what happens and how to solve?

None of the App Inventor distros have background services feature.
It would be great but not available yet.
There’s a block to keep the screen from turning off though. Would that be useful for you?

1 Like

There are many misconceptions about the term “background”. Background means only that the app is not not visible (eg after pressing the home button or the app is in sleep mode, black screen), but is not closed.

So if the screen goes into sleep mode or you press the home button, the sound (ExoPlayer) should continue to play …

Background task means that the app can execute somthing even when it is closed, this is not possible with Kodular and the other builders (Ai2, Thunkable etc.). So when the app is closed the sound will stop.

So if the sound stops even though the app was not closed, you’re making a mistake somewhere.

I tried here and this doesn’t works in this case, because if i want to block my phone the screen goes off… :confused:

So… it works for some minutes, and occour the problem. After some tests, it looks like the internet goes down, but i think it is not the correct problem, maybe battery optimization or anything…

So… i make some tests, and even if it’s an app with a button and exo player only, after a while it happens that sound stop…

Maybe related to this:
(search for: “WiFi connection will be deactivated / interrupted in standby / sleep mode”)
https://groups.google.com/forum/#!searchin/mitappinventortest/streaming|sort:date/mitappinventortest/Tz-h1ZysGxY/wxBjysQUBgAJ

Does the problem only occur with WiFi or also with 3/4G LTE?

PS: We discussed the problem intensively among the power users & the MIT team … so far without a solution. (Which devices are affected?)

Yeap… i tried now… the problem occours with WiFI and 3G/4G LTE…

I see the discussion, and now i think the problem is with Battery Optimization, because i tried use connected in power supply and the problem doesn’t occour…

I read some posts to solve this (battery optimization), but all of them have permissions to put in AndroidManifest.xml and execute an Android function to disable battery optimization for the app…

I tried all settings (including all battery optimization settings) on a Galaxy Note 8, API28 without success.
The important setting is: “KEEP WIFI ON DURING SLEEP” and this has gone (in Android 9).

Use a web viewer. The web radio will continue in background

This does not help at all, it is due to the WiFi connection, which is interrupted in sleep mode on some devices.

And what happens in this case with other apps? Like whatsapp or telegram? They run in background and are listening if have new messages to notify…

Translated from German:
“I have the same problem. I’ve been struggling through the forums for days and can’t find any suitable solutions. For me, Whats App and GMX are affected.”


I confirm closing the application after a few minutes.
Tested on EMUI 8, 9, 9.1, 10. (Android 8, 9, 10)
Setting “no saving battery” give nothing.
All other settings do nothing.
I had to add the screen turned on permanently to use the radio.
Unfortunately, Kodular has it and nothing can be done.

Yes, but eg on a Samsung Galaxy 8(+) with Android 8 and on a Pixel XL with 8.0 there should be this setting “Keep WiFi on during sleep”:

As I said, this option is no longer available on a Samsung Galaxy with Android 9.

In Huawei is available. It also gives nothing. The application stops working after a few minutes regardless of the system settings.

Does this only happen in sleep mode or even when the app is in the background (e.g. the home button was pressed)? How long does it take after the device has switched to sleep mode before the sound stops?

This happens regardless of the screen being turned off. Just use another application when you have not turned off ours. It will also be turned off after a few minutes.
I never counted that time. It takes from a few to several minutes.

Exactly it happens… the app freezes some time after the screen turned off…

and grafik doesn’t help?

so… i have a galaxy S8 with Android Pie… i don’t have this option… :confused: