Android Question What metric can I use that will indicate the devices' resources are getting low?

JohnC

Expert
Licensed User
Longtime User
I would like my app to detect when a device's resources are getting low, which might mean my app is about to be killed by the OS.

I thought that one of the memory metrics would work, but even the "Available Memory" method stayed the same:


So, is there some other metric that my app could use to detect a downward trend in that metric?

P.S. My app will not be in the play store, so I am not bound by any newer SDK restrictions.
 

JohnC

Expert
Licensed User
Longtime User
I understand that it should work that way, but there is a test app called "Benchhole" that stress tests a device and will cause Foreground service apps to be killed.

This page goes into more details about it:

Even with setting StartServerAt[Exact], my foreground service app will be killed by this stress test app and it will properly restart most of the time, but sometimes it won't restart and needs to have it manually restarted.

I am looking for some way to detect when the device is under stress that might soon kill my app and warn the user.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Foreground services are not 100% the same as visible apps and can be killed by the OS.

Running a service in the background for a prolong time is challenging. I don't think that monitoring the system resources will help. You should expect the process to be killed from time to time.

The UI cloud was made of multiple devices which run the client app for months without any intervention. I implemented it using two apps. The main app and a watchdog app that is responsible for starting the main app every 30 seconds.
Newer devices were less stable than older devices.
 
Upvote 0
Top