0

I am using following code:

for(int i = 0; i < numOfTasks; i++)
ActivityManager.RunningAppProcessInfo task = tasksP.get(i);

from task.processName I am getting process package name e.g com.android.alarmclock (running app)

I want to kill this application, is there anyway to do that ??

Arpit
  • 6,212
  • 8
  • 38
  • 69
Syed
  • 550
  • 1
  • 7
  • 22
  • This is such a duplicate it's not even funny: http://stackoverflow.com/questions/6303615/how-do-task-managers-kill-apps http://stackoverflow.com/questions/4504091/how-to-kill-other-apps http://stackoverflow.com/questions/2951660/kill-an-app-package-in-api-8-froyo – Neil Traft Jul 05 '11 at 12:12

1 Answers1

1

There is two way of killing an application

/* Way one */
android.os.Process.killProcess(android.os.Process.myPid())

/* Way Two */
System.exit(0);
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
  • None of them will work if your activity stack is not empty. Android will restart the process and spawn the topmost activity from the stack. – JBM Jul 05 '11 at 12:04