Affiliate links on Android Authority may earn us a commission. Learn more.
Powerful automation tricks and hacks for Android using Tasker, IFTTT, QPython and more
One of the coolest things about Android is undoubtedly just how much it lets you do without needing to root your device or otherwise modify it. Out of the box an Android phone is yours to customize, tweak and hack to your heart’s desires. If you want to use it as-is then you can, but if you’re more ambitious then the sky is the limit.
We’ve covered tools like Tasker and IFTTT here before and seen what kind of extra functionality and automation they can add to your phone. But it’s when we start integrating these different services, calling on others and adding a little light programming that things can get really interesting. So, let’s see how we can use a phone to do everything from reading out new Tweets to scraping the web for interesting content and sending it to our computer.
Tasker – For creating a working APK with zero code
Tasker is an app that can turn your smart phone into a super-smart phone. I won’t go through everything that Tasker can do or how to do it right here, as that has been covered before. Essentially though, it allows you to create profiles that include contexts and actions relating to the state of your phone or other variables. So you might mute your phone after 8pm for instance, or switch on the WiFi once you get home after work. So far, so standard!
Only things can get a lot more elaborate once you start using multiple different actions and dependencies (IF statements), along with ‘scenes’ that are basic GUIs for your apps and functions.
What’s more, is that you can actually use Tasker to create stand-alone APKs that other people can install on their phones! You can’t sign these apps (yet) so they can’t be distributed on the Play Store – but for easy access to functionality you’ve created yourself or for sharing hacked-together solutions with friends, it’s great.
All you need to do is to download a plugin for Tasker called ‘Tasker App Factory’. This app is free and once installed, you’ll be able to access it through the main Tasker app. Simply long click on a task, then choose ‘Export’ and ‘As App’. For this to work, you’ll first need to choose an icon for your task, which you can do by selecting it to edit from the ‘Tasks’ tab and then pressing the grid of squares in the bottom right corner. Make sure this isn’t too large (you can borrow an icon from an existing app) and you’ll be good to go!
Remember: to install these apps, the recipient device will need ‘allow app installs from unknown sources’ enabled in the settings.
Tasker + QPython3 – For building better apps
If you’ve seen my post on Python for Android, then you’ll know that another easy way to build some basic applications for Android is with QPython3. Only problem is that it’s inconvenient at best to make these into APKs…
Fortunately though, we can get Tasker and QPython3 to work together thanks to another plugin called QPython Plugin for Tasker. This one isn’t free – it’s £2.79GDP, so should be around $3.45USD – but it works well and if you enjoy nerdily hacking your phone, then you might find it’s worth it! QPython3 itself is free on the other hand and can be downloaded from the Play Store. It’s one of the easiest ways to dip your toes into a bit of programming on an Android device and I highly recommend giving it a go.
With QPython Plugin for Tasker, you can then add a task that will launch any of your QPython3 scripts. If you then package that task as an APK, you’ve then given yourself a convenient way of quickly launching your scripts to play games, access calculators and databases or automatically do some web scraping…
What else can we do with this pairing? Well, using the Python Android Scripting Layer for instance it is possible to access some additional hardware functionality. Whenever I think of automation and technology, I tend to think of Jarvis from Iron Man. So, for example then, we could get it to welcome us when we boot the phone.
The following script will say ‘Hello Adam’:
import sl4a droid = sl4a.Android() droid.ttsSpeak(“Hello Adam”)
And if we launch this script with Tasker whenever the phone boots, then we have a fun little ‘Jarvis’ type feature. Except it often takes so long to kick in that it can be a bit disappointing.
Unfortunately, there is no way to easily pass variables from Tasker to QPython3 but if we get a bit creative we can McGyver our way around that. All we need to do is to save a file through Tasker (File > Write File) and then read the contents of said file through QPython3.
Tasker + QPython3 + IFTTT – For reading out your Tweets
IFTTT is essentially Tasker but for your web apps and social media accounts. It lets you set up relationships between tools like Twitter, Facebook, Alexa, Google Drive and your phone (via the app). IFTTT supports a huge number of services and the total is growing all the time, which lets you do some really cool stuff.
Again, I won’t go into detail on how to use IFTTT as you can find instructions easily and it’s pretty simple anyway. What we’re going to do is create a new ‘Applet’ where the IF element is sending a Tweet from Twitter with a particular hashtag (I chose #sendtophone) and the THEN portion sends a notification via the IFTTT app (which you will need installed on your device) containing the text from the Tweet minus said hashtag.
With this in place, we can go about creating another QPython3 script. This will read a text document stored on the device called messages.txt in just the same way that it read the ‘welcome’ message earlier.
The code will look like this:
import sl4a droid = sl4a.Android() file = open(“/mnt/sdcard/message.txt”, “r”) droid.ttsSpeak(file.read()) file.close
I saved mine as ‘readtweet.py’. To learn more about saving and opening files, check out this resource.
You’ll need to grab yourself another plugin from the PlayStore, this time called ‘AutoNotification’. This is going to let us read the text of our notifications; otherwise Tasker is limited to reading only the titles of notifications. Note: AutoNotification is not free, but if you just want to test it out, then you can try it for 7 days.
With this done, we can now create a context that will intercept notifications (make sure to set the app to IFTTT) and then use a task that will write our messages.txt file (with ‘Append’ off, so that each new Tweet erases the previous one) and then run the readtweet.py script using QPyPlugin. You want to make sure that the file you create uses the string variable ‘%antextbig’ which is going to give you just the body of the notification when expanded.
Give it a try – Tweet something with the hashtag ‘sendtophone’ and after a couple of seconds, it will be read out in eerie computer voice on your phone!
This isn’t a particularly useful tool (unless you just want to creep people out) but you can use the same process to do all kinds of other funky things. For example, if you want to make sure you don’t miss Tweets that you’re mentioned in, then you could change the IFTTT applet so that it’s Tweets that mention you that get retweeted.
The current set-up has a limitation, which is that it will read out any IFTTT notification, which becomes an issue if you have multiple applets running. A simple solution would be to look for the contents of the string (either in Tasker or in QPython3) or to only trigger the sequence if the title is correct.
If you want to use your phone as a secret recording device then you could make a similar set-up where a certain Tweet would trigger and script that turns on the microphone and saves the file in a specific location.
Tasker + IFTTT + Alexa + Reverb – For voice controlling your phone’s functions
I got an Echo Dot for Christmas and have been loving it, but I’ve always felt it’s a bit of a shame I can’t use it in conjunction with my phone’s capabilities. Or rather couldn’t! Lately, I’ve been using a very similar combination of IFTTT and Tasker in order to use Alexa to do just that. For example, I can use Alexa to launch an app of my choosing or change various settings.
Doing this is simple as pie. Just create an IFTTT applet where Alexa is the trigger and choose the option ‘Say a Specific Phrase’. This phrase has to begin with ‘Alexa Trigger’ but you can select the text that follows. For example, we can say ‘Alexa Trigger camera’ and then send a notification through the IFTTT app.
In Tasker, we simply intercept our notification in the precise same way and then launch the camera using a task. Likewise, we could use another voice command and launch YouTube or Spotify, or we could use a voice command in order to start playing certain media. You could control the volume too, change the brightness etc. This is mostly going to be used for showing off to friends, although seeing as the ‘Tell Alexa to Find My Phone’ function doesn’t work in the UK yet, I’ve used something similar to create my own solution.
If you want to add multiple Alexa features, then I would recommend creating lots of IFTTT applets to handle the different commands, but only creating one QPython script to parse the different commands and trigger the chosen response.
Note: One more little tip for Alexa users: make sure you get yourself the Reverb app. This is an app that turns your mobile into a remote for Alexa (so that you don’t have to buy the $30 accessory). This lets you add a voice assistant to your phone with any features you choose to set-up. Of course you could just use the ‘Voice’ context to do that through Tasker alone though…
Tasker + QPython + DropBox + DropBox Sync – For saving your favorite webpage
Okay, seeing as we’re getting pretty nerdy here, why don’t we take this to the next level and do some serious automation? To do this, we’re going to build a ‘web scraper’ in QPython which is essentially a tool that reads information from the web. Then we’re going to save the page in a folder on our phones which will then be synchronized onto a PC when it’s booted up.
First, you’ll need QPython – as opposed to QPython3 which we’ve been using so far. QPython uses Python 2 rather than Python 3 and if you want to learn more about all that, then check out the article on Python I mentioned earlier. Either way, both apps are free and they’re both useful for different things so download them both!
Now, head into there and select Libraries. Scroll down and select ‘Install with official pypi’ by clicking ‘Pip Console’. In here, you can now install additional libraries which are additional code that we’ll have access to from within our apps.
We want two libraries in particular, so type out the following two commands and wait for them to do their thing:
pip install BeautifulSoup pip install requests
Now, head back into the editor as usual and type out the following code:
import requests from BeautifulSoup import BeautifulSoup url = “https://www.androidauthority.com” response = requests.get(url) html = response.content soup = BeautifulSoup(html) print (soup.prettify()) file = open(“/mnt/sdcard/sync/androidauthoritytoday.htm”, “w”) file.write(soup.prettify()) file.close
What we’re doing here is to grab the front page of Android Authority and then ‘beautify it’ before printing it to the screen and saving it as a HTML file that we can open in a browser. I’ve created a new folder called ‘sync’ and you’ll need to do the same (or choose an existing folder on your device).
BeautifulSoup is an incredibly useful tool and we can use it to do much more complex scraping – with a little hijinks you could easily enough get it to grab the latest scores from your favorite sport, the news headlines etc. For a great and super in-depth introduction to web scraping with Python, check out this post.
So where does Dropbox come in? Well, that’s how you’re going to synchronize your folders. Just install the Dropbox app and then find another app called Dropsync. For the basic functionality, this app is free. Basically, this app allows you to get Dropbox to work as it does on your PC; so that files saved in a particular folder will instantly be synchronized and uploaded.
Choose the folder you created to store your scraped web page into and make sure that you allow DropSync to work on 4G and to sync regularly if you want to keep it up-to-date. Of course, that means you also need to avoid storing any large files in here though!
Now, by using Tasker to trigger the Python script to run at regular intervals, you can get the latest news from your favorite site stored in the cloud on a daily basis.
And there’s way more you can do with just a few extra tricks and tweaks. For example, you could automate a social media channel by using Twython (a Python library that works with Twitter) in order to post the information you scrape!
Your smartphone can do all sorts of amazing things once you dig a little under the surface. A lot of this functionality could be accomplished more effectively using a bit more advanced code, but the point of this post is to demonstrate what’s possible and readily available to everyone. Without needing to have a degree in computer science, you can get your phone to do some pretty intelligent stuff and find ways to get it to work for you and make your daily routine that little bit easier.
I hope you found at least a couple of tips and ideas in this post interesting or useful. If you did, then be sure to let us know in the comments section down below what cool automation hacks and tricks you came up with!