android - Terminating a third-party application like the button "App Info -> Force stop" does -


i can terminate application this:

android.os.process.killprocess(android.os.process.mypid()); 

how can terminate application (or ones allow that) button app info -> force stop does?

firstly cannot kill processes application has not created. processes started application can kill them using

public static final void killprocess (int pid) 

docs

if want kill background processes can

public void killbackgroundprocesses (string packagename) 

docs

but need kill_background_processes permission that.

afaik kill process, won't kill task in memory. when app restarted, activity stack/task re created last time unless ofcourse system kills freeing resources.

so afaik can never achieve same effect app info -> force stop programmatically because there no way clear tasks in memory , system can that.


Popular posts from this blog