-2

I'm looking for a way to clean the android recent app list programmatically. The list which pop up when the "2 superposed boxes" button is pressed.

Has anyone a idea or hint for me, how can I do this ?

The background is, I develop a little app and one requirement is, in "safe mode" the list must be empty. My idea is to clean the list on shutdown.

Thanks, André

Andre Kullmann
  • 121
  • 2
  • 6
  • 3
    It is not possible to remove apps that you do not own from that list – cjds Aug 03 '15 at 19:54
  • 3
    That sounds like an extremely bad user experience. The user might have important things going on in the running apps. Closing them programmatically is very rude. – StilesCrisis Aug 03 '15 at 19:56
  • 2
    Why in the world would you want to do this? What's the point? – Kevin Krumwiede Aug 03 '15 at 19:57
  • I think you're looking for http://developer.android.com/guide/topics/manifest/activity-element.html#exclude why would you care if other apps are in the recent list as long as yours isn't? – JohanShogun Aug 03 '15 at 21:20
  • With Android 5 Apps in the hone screen can be startet in safe mode, that sucks. So i develop a small app which modified the Shortcuts and avoid the launching in Safe Mode. But the Apps can be startet from the recent List. This sucks – Andre Kullmann Aug 06 '15 at 11:32

1 Answers1

0

Just for your curiosity yeah its possible, But It's a very bad decision since the user might not want his/her important task to be killed.

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);
   }
Prokash Sarkar
  • 11,723
  • 1
  • 37
  • 50