What is “Don’t Keep Activities” in Android?
Have you ever came across an option under Developer Settings on your mobile phone and wondered what is it all about? If you play around with your phone’s settings, then you will discover an option depicting “Don’t keep activities” hidden under “Developer Options”. For this, you have to be in developer mode first which can be enabled by tapping on the build number seven times.
After entering the developer mode you can see the developer options as given below
What is “Don’t Keep Activities”?
Basically in layman’s terms Don’t keep activities is a function whose job is to kill every app as soon as the user comes out of it. This means that the Android has to load the app’s resources every time the user opens as it does not have the cached data or memory of that specific app to perform that task.
From the Titanium doc:
Don’t keep activities under the Developer Options menu. When this option is enabled, the Android OS will destroy an activity as soon as it is stopped. It is intended to help developers debug their apps. For example, it can simulate the case that Android will kill an activity in the background due to memory pressure. In normal use, it is not recommended to turn this option on because this may lead to unexpected issues on the apps, such as freezes, force closes, and reboots.
So why is it present at the First Place and what are its Advantages?
Google has mentioned in its docs that this option was present to help developers to identify the reason(to debug) if there were sudden crashes or reboots or freezing of the app. This is also useful for the developer to check the saved instance state of the app and to check if the app is consuming more memory on the ram than needed. Hence It will be useful for writing the code accordingly.
- It is not recommended for normal users to enable it as it can have unnecessary consequences
- It will slow the app drastically as it does not have cache memory(type of memory) to access it when the app loads and has to fetch the resources every time!
- Some suggest enabling it to increase battery life but it does more bad than good
Hence if you are a developer, don’t hesitate to enable the option, and if you are not then it is not recommended to enable it.