Android Question [SOLVED] - Running a streaming app without it being put to sleep by Android

rleiman

Well-Known Member
Licensed User
Longtime User
Greetings,

Android is killing (putting to sleep) my radio streaming app.

Originally, I placed all of the app code in the main module. It works fine for long periods of time only if I stay in the app. If I exit the app or turn the phone screen off, Android was killing it after about 3 or 4 minutes as it was streaming the music.

Steps I took to stop the problem:

I moved the coding that starts the music streaming to the starter module which I thought is never killed by Android. I guessed wrong. After about 5 minutes the music stopped. I went online and they told me to to to the App power management of the phone's settings and in Apps that won't be put to sleep I added the streaming app. Pow, Android ignored my request not to put it to sleep after about 10 minutes. I went through the forum to see what other people were doing to stop the app from being killed and they were using lock.PartialLock in their Service_Create. Again Android ignored that command. It was killed after about 25 minutes. ?

Can you tell me what all of you doing to your streaming apps so Android leaves them alone?

Thanks.
 

rleiman

Well-Known Member
Licensed User
Longtime User
I'm also trying a technique someone is using. It involves adding an additional service module and starting it from the main module. The service module is using a notification. The notification shows up in the notifications drawer that you can pull down from the top of the screen. So far it's been streaming the music for over 40 minutes. I will post the coding tomorrow based on the link you gave plus the one I'm testing now.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I'm also trying a technique someone is using. It involves adding an additional service module and starting it from the main module. The service module is using a notification. The notification shows up in the notifications drawer that you can pull down from the top of the screen. So far it's been streaming the music for over 40 minutes. I will post the coding tomorrow based on the link you gave plus the one I'm testing now.
check this - based on the background timer (app waits for 30 minutes of inactivity and them shows a waring message when the user returns to the app)
 

Attachments

  • Test.zip
    9.9 KB · Views: 351
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
check this - based on the background timer (app waits for 30 minutes of inactivity and them shows a waring message when the user returns to the app)
Very nice technique and very helpful.

For now we are going to go with having the app use the additional service module running in the foreground because it worked overnight and because we are too far into the project. We will be releasing it to the play store soon and will rewrite it as a Pages app following the suggestion by Erel in the next update of the app.

This brings us to a question. Will we be able to release the pages version on the play store if we name the app the same and also use the same package name and use the same private sign key?
 
Last edited:
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Very nice technique and very helpful.

For now we are going to go with having the app use the additional service module running in the foreground because it worked overnight and because we are too far into the project. We will be realising it to the play store soon and will rewrite it as a Pages app following the suggestion by Erel.

This brings us to a question. Will we be able to release the pages version on the play store if we name the app the same and also use the same package name and use the same private sign key?
Keep in mind that B4XPages requires Android 10+ phone. It doesn't work on Android 8 or 9.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Keep in mind that B4XPages requires Android 10+ phone. It doesn't work on Android 8 or 9.
Where do this info came from?

I can´t remember seen any such Info.

You need to use B4A 10+. But this is not related to the Android Version.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Where do this info came from?

I can´t remember seen any such Info.

You need to use B4A 10+. But this is not related to the Android Version.

I have B4A 10.0

I tried to create a simple project and ran it on my Android 10 phone with no problem. The same project on my Android 8 didn't even install at all - error was that package can't be parsed.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I have B4A 10.0

I tried to create a simple project and ran it on my Android 10 phone with no problem. The same project on my Android 8 didn't even install at all - error was that package can't be parsed.
Tried the same project B4xPages to run on the same Android 8 phone yesterday - works fine. Weird.:)
 
Upvote 0
Top