kehnar
kehnar

Reputation: 1387

How to kill running application in android

I am writing a application which can kill other running application. For this I am using following code

int pid = process.pid;
android.os.Process.killProcess(pid);
Log.e("killed",process.processName);

I am able to display all running application. But the above two line of code is not killing the process of application(com.sample.mango). Also I can see several task killing app in the market.

So my question is -- Is it possible to kill running application from other application?

If yes then what is way to kill? (why the above code is not working)

Upvotes: 0

Views: 589

Answers (3)

Zharf
Zharf

Reputation: 2658

You could also try sending SIGNAL_KILL to the pids.

Upvotes: 0

Tamás Szincsák
Tamás Szincsák

Reputation: 1031

From the documentation:

Kill the process with the given PID. Note that, though this API allows us to request to kill any process based on its PID, the kernel will still impose standard restrictions on which PIDs you are actually able to kill. Typically this means only the process running the caller's packages/application and any additional processes created by that app; packages sharing a common UID will also be able to kill each other's processes.

That's why killProcess does not work.

You should try killBackgroundProcesses instead. Don't forget to add KILL_BACKGROUND_PROCESSES to your AndroidManifest.xml.

Upvotes: 0

TeaCupApp
TeaCupApp

Reputation: 11452

Does Android allows these kind of apps? Isn't this a service provided by operating system rather then third party App. I would hate if my app is getting killed by some third party App.

Upvotes: 1

Related Questions