There is a tutorial made by Joao Dias showing you how to set NASA daily pictures as wallpaper. I thought I would up the ante a little. When I started to work on this project, I thought it will be a quick one. Turned out the solution was more difficult to find than I thought it would. I wanted to post smaller tutorials with the benefit of posting more often, and I spend about 4h googling for the solutions to a non-existing issue! I REALLY hope you will like it ha!

Without further introductions, here is Google Maps traffic wallpaper which will be set for a brief period of time before commute to and from work. Perhaps you will ask – can we just query the google and get the traffic information to a destination? Yes, you can do that, however, a nice image tells you more than an ETA estimation. There is really no reason against getting other screen grabs this way.

Map – the issue

mapThe information is best obtained by taking a screenshot. This is not that simple if your phone has a screen lock on it. I can force the Tasker to take the screenshot – whether with a Run Shell, AutoTools etc. But most of the time I would end up with a black screen, or lock screen picture.

I had to scrap this idea and come up with something else. While googling for solutions I came across screen shot services like screenshotmachine.com. The free account allows you for 100 calls  per month. The API is pretty much self-explanatory. I got stuck for a long time with the fact that my link was able to pull a correct image via the web browser but no through the HTTP GET action. I managed to bypass the link issue by using the google URL shortener. It worked.

Profile

screenshot_20161013-063042The context is simple (feel free to change it). I’m using a time condition to change the current wallpaper for 30 min before my commute to work, and before my return home. Outside of these times, the wallpaper will revert to one of your choices. You can use the Tasker to set the wallpaper, and if you on Android 7 you can use AutoTools to set the screen lock wallpaper separately.

Task

Formatting the link

As per API guide the link looks like this:

[code language=”bash”]

http://api.screenshotmachine.com/?key=YOUR_API_KEY&size=F&format=PNG&url=URL_SHORTENED_BY_GOOGLE

[/code]

Open up the google maps and get the directions for your commute (both ways) and cut the link short before the encoded part. Here is my example and here is where it ends:

[code language=”bash”] https://www.google.co.uk/maps/dir/Field+View+B+%26+B+Yarm,+Green+Lane,+Yarm+TS15+9EH,+United+Kingdom/Manchester+Piccadilly+Station,+Manchester+M60+7RA,+United+Kingdom /(dont need the rest)……/data=!3m1!4b1!4m13!4m12!1m5!1 [/code]

Use that google code with the URL shortener if it doesn’t work directly for you to compile the final screenshot API request. I’m going to use HTTP GET to receive the picture of the current traffic and route options. As both routes will use exatly the same routines but different links it makes sense to set the shortened links as variable %UrlCommyte. In the action set the  link + the variable  in the Server:Port. Set the Mime Type to Image/png and select a file location. This is where the picture will be stored. Before the image can be used – we will need to crop it. this-one

Cropping

If you selected the image to be full size (X) you will end up with a consistent image of 1024 x 768px. This it far from perfect and the crop is in place. You can use both information if you wish. The list view and the map view but I will show you the cropping to get the map. You will need 3 actions. Load, Crop and Save image. Crop from the left 45%.

Wallpaper

Using Muzei and AutoTools you can set the new wallpaper to both home screen and lock screen. If you are using Tasker actions only you will be limited to a home wallpaper only. Select the correct files and you are  ready to rock.

Finishing the project Google Maps traffic wallpaper

After reading all this, I’d assume you will have no problem with setting up a profile for the reversed journey. You don’t event have to change the file names.  only reverse the link and set up a  new time.

[toggle title=”Google Maps Traffic Wallpaper”]

[code]
Profile: Going To Work (4)
Time: From 06:45 Till 08:15
Enter: Get Map (3)
Abort Existing Task
A1: Variable Set [ Name:%UrlCommute To:SHORT_URL_HERE Do Maths:Off Append:Off ]
A2: HTTP Get [ Server:Port:http://api.screenshotmachine.com/?key=YOUR_KEY_HERE&size=X&format=PNG&url=%UrlCommute Path: Attributes: Cookies: User Agent: Timeout:15 Mime Type:image/png Output File:/sdcard/Tasker/new.png Trust Any Certificate:On ]
A3: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ]
A4: Load Image [ Source:/sdcard/Tasker/new.png Max Width Or Height:0 Respect EXIF Orientation:Off ]
A5: Crop Image [ From Left (%):45 From Right (%):0 From Top (%):0 From Bottom (%):0 ]
A6: Save Image [ File:/sdcard/Tasker/new1.png Image Quality:85 Delete From Memory After:On ]
A7: AutoTools Wallpapers/Muzei [ Configuration:Lock Screen Wallpaper: /storage/emulated/0/Tasker/new1.png Timeout (Seconds):60 ]

Exit: Reset (5)
A1: AutoTools Wallpapers/Muzei [ Configuration:Lock Screen Wallpaper: /storage/emulated/0/Download/IMG_20160923_104847.jpg Timeout (Seconds):60 ]
[/code]

[/toggle]

[box type=”info”]
You will need:
Android ver: Any (done on 7.0)
Apps: account with screenshotmachine.com
Plugin: AutoTools (optional)
Needs: no special requirements
The complete project file is available here: google_maps_traffic__wallpaper-prj
Mobile users, long press on the file and ‘save as’, all users please rename the file to .prj.xml
Consider supporting the website – links in the menu above and a side menu. [/box]