Question

I am trying to kill an application programatically as Android does when there is overload in memory.. I had searched many post in stackoverflow itself regarding killing of an application, all concluded by saying it is not possible by the user to do at a point of time but it can be done by following the standards like finishing a activity once it moved and at last call killProcess(pid) fn.

My doubt is killing an app is force stopping it and clearing the data it holds.. Is it possible to do these programattically? If so we can acheive killing process programatically..

Regards,

Deepak

Was it helpful?

Solution 3

I could get a solution to Clear the Application data programatically.. I could acheive it by Reflecting the method which is used to do clear data when we click the Clear Data button in the Settings->Application->Manage Application->App Name.. I had found that method from the android source..

Note:

The clear data fn only clears the data but not Force Stopping the app in 4.0+ , but the app is force stopping also while clearing the data in 2.3..

Thanks for the replies

OTHER TIPS

yes you can do it with one line . but you your device need to be rooted first

android.os.Process.killProcess(pid);

You can stop any other running application by it's name like this:

ActivityManager am = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses(appPackageName);

This code will work in API8 or hier.

What do you mean by "clean data"? If you mean release memory that is used by currently running process - it will be done automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top