Tasker and Google Maps

Author

Dheepak Krishnamurthy

Published

December 13, 2014

Android Projects

This is a small tutorial on how to use Python with SL4A.

When Google Now first came out, it would tell you which bus you could take at what time to get to your meeting or event on time based on the location and time information available in Google Calendar. It’s every student’s dream, especially in countries like the United States or Singapore, where transit navigation is very accurate.

I loved the idea, but I wanted it to be ever so slightly better. For example, I wanted my phone to inform me well in advance at what time I should consider leaving home to get to the bus on time. I also wanted information on earlier and later buses, so I could have knowledge of my options, very similar to the way it shows in Google Directions.

Enter Tasker. I have a profile set up, which responds to a Google Calendar event reminder. (Tasker requires accessibility access for this by the way.) All my events in Google Calendar have a reminder set to pop up one hour before the event. This triggers a python script that pulls the next event details from Google Calendar, strips and parses the necessary information. Using my current location, the directions to the location is fetched and parsed again for transit details. Tasker then displays this as a notification.

This is very similar to a thread found on XDA-Dev. The idea is based on the thread, but in the thread brandall decided to do everything in Tasker. While this is completely doable it made it a little complicated to debug. Also, the profiles attached in his thread require the calendar event to have the name Meeting and also require a description to be entered. Again, not something you cannot do, but you will have to invest a significant amount of time in case you want to make any significant change.

If you would like to setup something similar follow the steps below.

  1. Install Tasker, SL4A and the Python intepreter.

  2. Paste the python script from the link here in the SL4A folder. This script has to be modified depending on what you want done. To use information from your Google Calendar, you need to add your private Google Calendar link to the script. I’ve written this to pull Transit details from a xml data, but you can theoretically do anything.

  3. Setup a tasker profile similar to what I have below.

  1. The Task that will be performed when this context is triggered is setup as below.

  1. The above task turns on GPS, finds your current location using GPS and NET, stores the location data in a file and runs the python script. The python script uses the location data written into the file along with your next calendar event information to find out transit details. This then calls the show route task.

  2. The show route is attached below.

  1. All you need to do now is create an event on your Calendar with location information and you are good to go!

Here are some screenshots of what it looks like after you are done.

I’ve attached the xml from Tasker here so that it can be imported. Show Route and GetCalData. I’ve used Autonotification, a tasker plugin by joaomgcd to display the notification. You will need to use this if you want a button in the notification. This entire setup is currently in a primitive stage, I haven’t added any error handling or additional functionality but I intend to. I will update this post when I do that.

BeautifulSoup is supported by SL4A in python, which can make it extremely easy to parse information. I haven’t used it in my script though, since mine was a very small program. But it is nice to know that is an option. Big shoutout to PocketTables for offering a world of useful information on Tasker. I found their posts to be extremely helpful. Tasker is an amazing application and is extremely powerful. It can allow for a world of customization.

If you have any questions about this setup please do let me know.

Reuse

Citation

BibTeX citation:
@online{krishnamurthy2014,
  author = {Krishnamurthy, Dheepak},
  title = {Tasker and {Google} {Maps}},
  date = {2014-12-13},
  url = {https://kdheepak.com/blog/tasker-and-google-maps/},
  langid = {en}
}
For attribution, please cite this work as:
D. Krishnamurthy, “Tasker and Google Maps,” Dec. 13, 2014. https://kdheepak.com/blog/tasker-and-google-maps/.