I was experimenting with ActivityManager.killBackgroundProcesses in my application and notice something interesting. I hope someone on stackoverflow can shed some light on this.
So if I start an application, for example, youtube, I first see the list of video page, then I click menu->Settings, I will get the settings page. now if I click home button, which will put youtube to background. so far so good. Now if I run ActivityManager.killBackgroundProcesses to kill youtube application (or I use Advanced task killer which I believe using the same API), and when I launch youtube again, I see the setting page, not the default list of video page.
But if instead of doing ActivityManager.killBackgroundProcesses, I go to system settings->manage application->Youtube->Force stop, and when I launch youtube again, I get the list of video page, not the setting page.
So it seems that ActivityManager.killBackgroundProcesses is different from force stop as it still remembers the last task/page it was on before it was put to background, whereas force stop gives you a fresh start.
Anyone has good explanation for it? Is it possible in my code to do "force stop" to get a fresh start of the application?
Many thanks!
Well, I am not sure how use it exactly as I have never try before with apps other than mine, but mayby it would help - think about using: android.os.Process.killProcess(android.os.Process.myPid());
And about your question why system can stop and you can't. The truth is that system can more. More specyfic, when you press force stop button system is sending kill signal (signal 9) to process with given pid.
This is why I think the above function should help, because it is sending almost, if not exactly this same, signal.
Hope it will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With