1

I want to develop a task-killer . The task of this app is to kill background running applications . I have searched a lot in the internet and found the following code to kill installed application .

List<ApplicationInfo> packages;
    PackageManager pm;
    pm = getPackageManager();
    //get a list of installed apps.
    packages = pm.getInstalledApplications(0);

    ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

   for (ApplicationInfo packageInfo : packages) {
        if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue;
        if(packageInfo.packageName.equals("mypackage")) continue;
        mActivityManager.killBackgroundProcesses(packageInfo.packageName);
   }  

But this code only kills installed applications . I want to kill those apps which are running in background .I do not want to kill those apps without which android os will shutdown . Can you help me in this purpose ?

osimer pothe
  • 2,827
  • 14
  • 54
  • 92

0 Answers0