1

What code is required to keep an app live when it is "pushed" to the background?

My app USED to behave this way. If a user multitasked or hit home, my app would minimise, and they could later return to it. Now, and I have no idea what change I made to cause this, my app is closed by the Android system whenever it is minimised.

I have checked memory, and it doesn't seem to be an issue. My app is actually using LESS memory now than previously.

When the app is minimised and closed, OnPause and OnStop are being called for the current activity, but onSaveInstanceState is not.

SOLVED: It was caused by android:noHistory="true" in my manafest

ausgeorge
  • 975
  • 1
  • 12
  • 23
  • you will need to saveinstance when you do an onStop to your app – Gastón Saillén Mar 13 '18 at 03:18
  • For storing persistent data,you can save it in onPause.Refer https://stackoverflow.com/a/2909211/4989929 – Ronak Poriya Mar 13 '18 at 03:23
  • I am not asking how to store persistent data. I am asking if there's anything I can do to stop Android from closing my app when it's minimised. Some apps can clearly be minimised without being closed. – ausgeorge Mar 13 '18 at 04:06
  • You need to use partial wakelock to keep the CPU running. https://developer.android.com/training/scheduling/wakelock.html – Anuraag Baishya Mar 13 '18 at 07:24

0 Answers0