Question

Let's say I'm using an app which is both RAM and CPU intensive and I get a call which I'm bound to be on for say, a minute. In this case, I want to know what will be the fate of the application. Will it still continue its execution in the background and will its priority be changed?

Also, if at all the app uses higher amounts of RAM and CPU, is there any chance that the app will be shutdown by the android OS?

Please share any resources and documentation that discusses this subject. Thanks in advance. :)

Was it helpful?

Solution

Will it still continue its execution in the background

For at least a few milliseconds, yes. Regardless of how an application moves to the background, once in the background, its process is eligible to be terminated, to free up RAM for other apps. When that occurs depends upon a lot of variables -- it could be milliseconds, it could be hours.

and will its priority be changed?

Background applications' processes run in a class that helps limit their CPU utilization.

Also, if at all the app uses higher amounts of RAM and CPU, is there any chance that the app will be shutdown by the android OS?

Regardless of amounts of RAM and CPU, the app's process may be terminated by Android at any point when it is in the background.

OTHER TIPS

It's important to distinguish between the app itself and the Activity that is being obscured. An Activity is just part of an application. When an Activity is hidden certain lifecycle methods are called depdning on whether it is partially hidden (onPause) or fully hidden (onStop). This does not necessarily affect the background processes that you started before the Activity was obscured. Even when an Activity is hidden, the app still exists. Background threads and services you started while a given Activity was the foreground will still be running (assuming the OS is not low on resources) as part of the existing app process.

What you should do is think about how to handle the result of these background processes within the other lifecycle methods (e.g. onResume) should they complete durring or after the obscured state ends.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top