My app silently closes (after 18 hours running continuously plugged-in)

Hello,

First, thank you for the App Inventor IDE! Not only it invents but it’s a great invention itself! I really enjoy using it.

I’ve made a small app that connects to a BLE Arduino module. It does its job – sends an SMS if the Arduino is in alarm – but the app closes once in a while, say once per one or two days. I’ve searched the phone for various optimization plans and have switched off everything I’ve found. I am trying to print out various log items, like right after the start (when Screen1.Initialize) or after connection (when BluetoothLE1.Connected) but I don’t see any Close event or alike.

Would somebody advise how to troubleshoot? In particular, how to discover who initiates the termination?
If it matters, auto-reconnection goes well: BLE disconnects when not in range and connects when I bring it back. So a temporal disconnection, should it happen, doesn’t crash the app.

Thank you in advance!

  • Android is not designed to run apps for long periods of time.

From a previous forum discussion

  • Google revised how long an app can ‘work’ continuously since Android 8. It is not possible to keep alive an app in background or otherwise for a long time (. eg your one or two days).

A few months ago there was a discussion about long term use of a plugged in Android and discussed all the reasons why apps cannot run for long term; essentially because of ‘safeguards’ in the Android system libraries. Sorry, I cannot find it. Perhaps one of the other moderators can.

I expect your issue is your app/android device shuts down because the Android operating system tells it to.

Regards,
Steve

Seems true. Do you know if rooting should overcome it?

Rooting? I expect not since this shutdown is determined by the Android operating system.

You might try running this on an older phone (4.2.2) where the restrictions might not provide safeguards. Will that work? No idea. Try it and if your app is still running in several days, be grateful. Be sure and post the outcome results so others can benefit from your experiments. good luck

I don’t have an older phone. But a working ugly solution is to enable Developer options and select Stay awake. The app never closes, just every 18 h 12 min 15 sec (= 2**16 - 1 sec) BLE disconnects and quickly auto-connects back. Probably that was the moment when the app closed, I can’t track it since the signal “about to close” does not exist.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.