• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Keeping app alive when minimised?

Hi,

Is there a flag to set which tells Android to keep an app alive when it's sent to the background (e.g. minimised)?

My app "instantly" closes whenever it is minimised, but some other apps stay "alive".

Memory (needing to be released) is not an issue.

Thanks :)
 
When your app gets put in the background, the onPause() method is called. You have little control over this because it's invoked by the runtime framework.

https://developer.android.com/guide/components/activities/activity-lifecycle.html

What are these other apps that you think can stay "alive"?

If you need to run something persistently in the background, the way to do this is by implementing a Service

My OnPause only does one thing; save a single string to SharedPreferences. I have removed these lines, and the app is still closing.

Many, many apps remain alive during multitasking (ie minimising them and using another app and/or phone function like making a call). These apps don't have to be restarted.
 
Really? This attribute controls the history aspect of the Activity, and determines whether it should be removed from the activity stack. It has nothing to do with control over the application lifecycle.

https://developer.android.com/guide/topics/manifest/activity-element.html

android:noHistory
Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it's no longer visible on screen — "true" if it should be finished, and "false" if not. The default value is "false".

A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it. In this case, onActivityResult() is never called if you start another activity for a result from this activity.

This attribute was introduced in API Level 3.
 
Back
Top Bottom