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,418
  • 7
  • 36
  • 68
Syed
  • 530
  • 1
  • 7
  • 21
  • 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
  • 51,611
  • 53
  • 174
  • 242
  • 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