Kodular app "restarts" itself after so long in the background


I created a Bluetooth oriented app. I got everything working as expected. However, if I open another app, and leave the phone focused on that app for say 20 minutes. My Kodular BT app stops working, which was in the background. The BT device shows it is disconnected. I re-open my app, it refreshes, and I’m asked to repair my bluetooth device again.

What could be causing this? It is such a bummer after all this long work. I have enabled battery optimizations for the app and checks to make sure all my clock components are “timer always fires.”

Is this related to your other topic from which you removed your text? Kodular apps can not run in the background.

I did not receive any replies to that topic. I did implement a method for re-connection. In addition, to a ping pong much like how IRC server check clients. So onto the next problem was my idea.

By background, I mean open, just not in focus. It does run as I said, for the 20 or so minutes before it “refreshes.”

I’ll have to post a video.

This will happen because your device will kills background processes which are running from a while to save memory.

The more and more I look into this. I believe you’re right. Unfortunately, this is still happening with no solution unless the phone is rooted. Which I nearly bricked this Moto x4 last time I tried.

Please let me know if you know the solution to that problem with Android 9? I’m currently testing using the max process limit found in the developer, options which is 4 processes.

So it is related. It is not allowed to double post your questions. Stay with the topic you first created instead of opening another one.

Currently it is not possible to run Kodular apps in background. May be in future, so there is no solution for this problem right now.

If you want to run your app non stop then stay within the app or don’t let it run in background or you can engage your users in your app to keep working your app non stop.

You can also inform your users, if they minimize or closes your app then it stops working.

See also this thread: Webradio App: Doesn't work in Background

You can try TaifunBatteryOptimization extension:

Thank you for that extension suggestion. I have disabled anything of the sort from affecting the phone. I believe it is being killed due to memory management software. Yet, the phone has 1GB free. Still kills it every 5 minutes or so.

For kicks, I wrote an app to open my kodular app every 5 minutes :smiley: Works, but not nearly a preferable solution. Currently, I’m either rooting the phone to have more control with resource management. Trying to find professional help there. If that fails, I guess I’ll have to recode the app.

This is not a solution for your problem. You can control your device with this but not of your users.

I think, Engaging your users within the app is good option.

Yes. Turned out this app needs to be made in Android Studio and as a service. But, this is not an app I’m sharing nor a product for sale.

I came to my solution. Rooting the phone and using RAM manager for Android, to allocate more RAM for multi tasking, has prevented the system from “refreshing” my kodular app when not in focus.

I requested assistance from someone on Fiverr to root the phone. Worked out. I will take note of this for future Kodular apps. Thanks everyone for your advice on the matter.