Pages

Friday, December 20, 2013

Tasker for Android - A Basic Volume Changer

Let's see how it is actually done.

Tasker is a very powerful application on Android that allows a user to code a number of actions (here on known as Tasks) based upon a number of events and triggers in the Android OS. If that did not make any sense to you, let me try an example scenario: At 10pm your ringer volume is changed to 0. Where the time change is an Event/Trigger from the OS and changing the volume is a Task that you code.

It would take a great amount of time for me to now outline even half of the stuff Tasker is capable of, so let us just say that it can do almost anything that is capable of being done in Android. Setting your ringer volume is pretty basic, creating a full application is tough, but entirely possible.

It may be difficult to justify the $7 price tag for Tasker. ($2.99 at the time of writing, what a deal!) I won't lie to you, there is a steep learning curve for this app, if you are not going to dig in to learn and use this app, you should instead install a handful of other apps that will hopefully do the same tasks. Obviously, I think Tasker is worth it, and I am going to trickle out examples as we go, so you can just follow along if you do not wish to learn yourself.

Theory: When I create in Tasker, I always create my tasks first, and separate the tasks into as many individual pieces as makes sense. This way, I can call upon these tasks in any order I need later on. I'll explain in more detail as we go.

Let's not waste any more time, you want to know how to build the ringer volume changer. I will show you the basics first, then we'll spruce it up a bit after.

Ringer Volume Change - Task

Under the Tasks tab, click the + new button, you will be asked to assign a unique name to this task, be short but concise, for example 'RingVolZero,' this way I know exactly what this task is for when I go looking for it later. Then click the + again to add an actual action to this task.

You may play with the other settings, but not necessary for our purposes.

Click your back button, or the 'Action Edit' button in the top left of the screen to save and exit, taking you back to your Task overview. And back again, or 'Task Edit' button, to finish off creating this task.

First part is almost complete. Here's the thing, Tasker usually reverts a value back to what it was before a Task changes it, but I do not count on it, thus, we actually require another Task that performs the opposite action, let's call this one 'RingVolNormal.'

Again, you may play with the other settings, but not necessary for our purposes.

Exit out and your second Task is complete.

Ringer Volume Change - Profile

Now you get to choose how and when to use this task. Under the Profiles tab, select + and provide a unique name for this profile, maybe 'SleepyTime' or 'GoodNight'.

Category: TimeFrom: 10pm or your desired quiet time at night. Repeat: Keep Turned OFF!To: 7am or your desired wake up time.
Click the back button to confirm and exit.

You will now be presented with a list of the Tasks that you have created, choose 'RingVolZero.'

Long press the task name 'RingVolZero' and select the option Add Exit Task, the list appears again, this time choose 'RingVolNormal.'

You are done.

What happens now: at 10pm every day your action to turn the ringer volume off on your device will be triggered and at 7am every day your action to return the volume to normal is triggered.

Advanced Options

1. Weekends:

You may desire to use different times for different days of the week, you will need to duplicate the Profile as many times as needed to meet all of your different time schedules. In each, long press the Time, select Add from the options and add a Day trigger. Set the desired days for each time frame, and you are good to go. If you happen to create duplicate times for a single day, the first action will fire and the second will overwrite it, be careful.

2. Variables:

Need to be turned on by turning off Beginner Mode in the Tasker Preferences. In an effort to reduce the amount of hard coded values in your triggers, vol = 0, vol = 5 and so forth, it is possible to create and assign variables to these values. Explanation - the code above makes it so that every day starts out at Volume 5 (or whatever), using a variable would allow you to start the day out at the volume that your device was at before it was silenced the night before.

In the Vars tab, create a variable called '%CURRENTRINGVOL' (or another unique ALL CAPS name,) assign it any numeric value for now, but 0 is probably best.

What if an emergency call comes through? Feel free to create another Task and Profile that cranks the ringer volume to the max if a call comes in from specific users in your address book. Chances are that if mom is calling at 2am, it's important. For others, use variables to store the number and time of the last incoming caller, and if they call again in a short amount of time, turn the volume up temporarily to let the call come through. Using that same theory, have your device fire out a pre-written SMS to an incoming caller to let them know that your phone is in silent mode, you are sleeping and that they will likely not hear from you until morning.

4. Meetings and Movies:

Since you have already created the RingVolZero task, why not trigger it in another method. I will show you later how to do so from Zooper Widget and using NFC tags, but for now, there is a Tasker Task Widget (button) that you can put on your home screen, use it to call RingVolZero and with one click your device is silent for that movie, meeting, class... maybe then use the Task Timer widget to tell the RingVolNormal task to fire in 90 minutes (or as needed.) Finally, if pushing buttons is too much effort, you could trigger the tasks by geo-location or wireless network. So, if you connect to 'workwireless' or get within 100ft of the movie theater's Latitude and Longitude, RingVolZero is fired. And when you disconnect from work, or leave the area, RingVolNormal is fired.

As you can see, for even the simple task of turning the ringer volume off at night, there are many options and methods that can be utilized. It will take some time and practice to get it all straight. Also, for this example, I completely ignored the other Volume settings on your device, you will probably want to change Notification Volume to zero as well, but not your Alarm volume, unless you've created another Profile to turn your alarm volume back on before an alarm fires (hint, hint.)

Last thought on volume controls, I usually play music through my tablet to go to sleep to at night. I use Tasker to gradually reduce the volume and then stop the music playback after 30 minutes or so.

Check back later, I really do wish to provide more ideas and recipes for using Tasker. Maybe you would like actions to save battery, maybe you need a timer for something. Maybe you just want the screen to stay on longer for certain apps or maybe you wish to build your own custom music player. I haven't completed my music player, but I can get you started.

Finally, Taker Tasks and Profiles can be exported and imported. Feel free to touch base in the comments below and we will securely exchange contact info so that I can make the files available to you.