1

I am trying to write a process that kills applications running in the background but the applications are still showing up in the recent apps list and not dieing:

ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE);

            List<ActivityManager.RunningTaskInfo> processList = am.getRunningTasks(5);
for(int i=0; i<processList.size();i++){
                cProcess = processList.get(i).baseActivity.getPackageName();
                if(!allowedApps.contains(cProcess)){
                    am.killBackgroundProcesses(cProcess);
                    Log.v("","---------------------------------------------------------kill-----"+cProcess);
                }
            }
erik
  • 4,946
  • 13
  • 70
  • 120
  • 5
    Don't do this. Android has unique process lifetime management, and trying to fight against that mechanism will be a losing battle. – Chris Stratton Nov 13 '12 at 19:28
  • no i am building a launcher/kiosk mode for a retail client and we are trying to secure the tablet from accessing some third party applications – erik Nov 13 '12 at 20:17
  • Silly question, but do you have the `KILL_BACKGROUND_PROCESSES` permission in your manifest? Second, there may be better ways of securing a kiosk-mode app. Writing a "launcher" program without third party app's icons(or an app tray), for one. Overriding the system buttons(see [here](http://stackoverflow.com/questions/11882581/android-is-it-possible-to-disable-the-long-click-of-home-button-to-avoid-the-t/12652490#12652490) for example) is another. Killing third party tasks doesn't really keep people from accessing them, there are better ways to do that. – Geobits Nov 13 '12 at 20:59
  • i do have those permissions, and i have managed to skin the nav bar via a service class. we are running as a default launcher. I guess i was just trying to kill all apps currently running at time of install/initial launch to insure nothing is already runnning in the back ground.. or at least kill the "recent apps" button – erik Nov 14 '12 at 15:37
  • btw we are running Samsung galaxy tab 2 10" android 4.0 – erik Nov 14 '12 at 15:38

2 Answers2

2

There is (to put it lightly) a difference of opinion about the need for app/task killers. I've never used one, because I've never seen the need. Some people might feel differently.

I agree that the best way to "secure" a retail mode device is to disable parts of the UI that would allow someone to run a third-party app.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18
1

no i am building a launcher/kiosk mode for a retail client and we are trying to secure the tablet from accessing some third party applications

This is not possible, in any sort of reliable fashion, except via custom firmware.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @ CommonsWare i feel like you keep following my posts about my hacks.. i agree with you on this note, but our client won't let us root the device so i have managed to create a task that skins the system nav and via a "total hack job runnable" force user's into a password screen in order to get to system settings.. – erik Nov 14 '12 at 15:40