Code Code - 1 year ago 220
Java Question

How to close other apps

I have simple code for this problem.

ActivityManager activityManager = (ActivityManager) context.getSystemService(- activity -);
activityManager.killBackgroundProcesses(- package name -);


ActivityManager activityManager = (ActivityManager) context.getSystemService(- activity -);
activityManager.restartPackage(- package name -);

But i dont know what i can write on activity and package name areas.

Sorry for my English.

Answer Source

Most likely you can't kill another apps / processes other than your own, simply because how Android OS architecture is set up. Every app lives in it's own sandbox with given resources and access to foreign ones is restricted. Although, I guess if you have rooted smartphone and root privileges, you could achieve your goal in linux kinda way, that is sending kill signal to given PID, try that out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download