0

My application behaves a certain incorrect way after it is killed by the OS while running in the background. In trying to debug this, I've had to basically wait for the OS to do this on every go around - this is very slow, so I was wondering if there was a way of programmatically telling the OS to kill my app.

I have tried android.os.Process.killProcess(android.os.Process.myPid()) and finish() but those don't seem to produce the same behavior as the natural way does.

Does anyone have any suggestions?

John Roberts
  • 5,885
  • 21
  • 70
  • 124

4 Answers4

0

You could go on your phone to Settings | Developers Options and set 'Don't keep Activities' checkbox. I'm not sure about exact wording.

This way as soon as any your Activity is in background it immediately gets killed.

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
0

You can try setting on Don't Keep Activity feature inside Developer Options.

When you leave each Activity (Because you start another one), Android will kill it (When you are running on low Memory Android behaves this way). Setting this feature on, you will be forced to manage in the proper way the state of each Activity using onSaveInstanceState() and checking por savedInstanceState Bundle in your onCreate()

noni
  • 2,927
  • 19
  • 18
0

try the below process:

 go to settings->developer options->check the "don't keep activities" checkbox.
Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59
-1

Try to use the genymotion that is a excelent Android Emulator.
It let you set the battery level and other configurations that can finish your application and do what you want.