[Android Apps and Games] brandall:
Not using Tasker? Shame on you… Download your free trial here

The debate about whether or not to use an automatic task killer in Android is for another thread. The general consensus seems to be ‘don’t’, but regardless, we all have them in case of troublesome processes (even if you can long-press the back button) and therefore I’ve produced this tutorial to show you how to use Tasker to create one that you can configure how you wish, should you wish!

If nothing else, there’s a few good Tasker tips in here, that I’m sure will come in handy for your other profiles.

Let’s get on with it!

Preparation

For best practice, testing and understanding, you’ll need:

1)	A Terminal Emulator

2)	A Task Killer (!)

3)	The Locale Execute Plug-in for Tasker (make sure this is installed prior to importing the profile)

4)	A speech engine – Pico TTS for example.

The Short Winded Tutorial

It kills sh*t loads of processes.

Proceed to the download!

The Long Winded Tutorial

Import the profile and ‘un-tick’ it to make sure it is not active until you have edited it to suit your needs.

The trigger for this profile is time based and set up as standard to run every 30 minutes between the times you are likely to be using your phone. Be sure that the activation time does not match that of your AutoSync Profile that you may/should/could be using from here, or otherwise how often your standard email and widgets sync with their individual settings – you don’t want those processes being killed mid-sync.

In this profile, Tasker will use Linux commands via the Locale Execute Plug-in to kill processes you have specified. Let’s get familiar with them.

Open up the Terminal Emulator and type:

su

then:

ps

The current running processes will be listed. You’ll note that all applications you would want to kill are assigned a process ID (PID) and an application number app_** (listed under 'User'). The application process (process name) is listed at the end, such as com.android.google.browser.

A process can be killed using its corresponding PID. Try it with an application you see in the list (NOT A SYSTEM PROCESS!):

pkill 3456

Unfortunately, the PID changes and therefore is not a constant we can use to terminate applications. We therefore have to focus on the process name – bbc.iplayer.android for example.

Try killing an application by name (open it first, list the processes again to make sure it’s there and then see if it has gone afterwards by listing processes again):

pkill com.google.android.youtube

Sometimes a process is persistent and needs further encouragement (execution) to die:

pkill -9 com.facebook.katana

Sometimes a process refuses to die – this can be because there are other processes associated with it that are not killed by the above.

Killall -9 com.levelup.beautifulwidgets

That’s the process killing commands lesson complete and only leaves us with one small issue = What if you are using the process at the time? Obviously we don’t want the browser killed if you are in the middle of surfing, so we have to use a variable to make certain of this. The chosen built in variable is %LAPP, which is the last foreground application used. By making sure this isn’t killed, it’ll stop your current program being terminated in the middle of a message to someone! Therefore, each separate action to kill a process has an IF statement included to prevent the termination if that application is currently being used.

There are plenty of examples in the profile for you to use, but of course you’ll want to add your own entries in the KillProcesses task by:

+

Plugin

Execute

Edit

And then type (or even better paste):

@! pkill -9 and then the process name* (@! Stops the commands appearing on the screen)

Press the back button to save

Click IF

%LAPP

Click ‘~’ select ‘doesn’t match’

Enter the application name**.

Done

* The process name can be found and noted in the Terminal Emulator. Alternatively, often the process names are listed in the Task Manager you are already using.

** In the profile, there is a speech task, popup notification and a STOP task, these are there to discover the correct application name. Open the application you want to add to the list, long hold the home button and select Tasker and then press ‘test’. Tasker will say the name of the application and show how it is spelt on the screen. If the speech says ‘Launcher’, you may need to navigate back to Tasker (after opening the desired app) via the notification bar.

Copying all of the process names and completing the IF statements can be a little tedious, but when it’s done, it’s done… Test each new action to ensure the application is actually killed – just drag it above the STOP action. The Super User application may request permission first time (for each application command). Go to your current Task Manager, refresh it and check the application was terminated! If it wasn’t, try the ‘killall -9’ command detailed above. I have to use this for Beautiful Widgets and Titanium Backup as they are stubborn (and return again soon).

When you've completed your list, delete the pop-up, speech and stop actions and you're good to go.

Finally, it couldn’t be easier to create a widget for the home-screen to activate KillProcesses whenever you like. Hold down somewhere on the home-screen, select widgets. Select Tasker. Select Task. Select KillProcesses. Select your icon and hit ‘make widget’! Done!

There you have it! Your very own self created task murderer at the touch of a button!

Enjoy!

Shortfalls

You are unable to kill a troublesome process if it’s not in your task list!

Future Inclusions?

When setting this up, I had Locale write the process list to a text file. In theory it is possible to get Tasker to read this file, dissect it and therefore discover by the constant app_** which tasks are running and place the process name in a variable which then could be exported to Locale to kill (I think). This is waaay too much effort, but have a go if you want!

In addition, Tasker could compare the before and after (kill) process list and work out approximately how many applications it killed, displaying the number in a popup notification. Again, effort – go for your life!

At present a notification is displayed showing the last time it murdered something.

Please let me know if you have any sensible requests and your feedback is always welcome!