Detect if Google Navigation is in focus and act on it.

844 views
Skip to first unread message

Vernon Gibson

unread,
Oct 22, 2013, 10:32:10 PM10/22/13
to tas...@googlegroups.com
Something I'm trying to do requires that I know when Google Navigation is active and in focus. 

What I'm working on is overlaying the current speed as well as some media buttons so I can keep my navigation active and visible but still be able to play/pause/skip media and see my current speed.

I have the overlay working and speed detection and stuff working but the problem I'm having is if I go to any other app the overlay stays active and on top. Also, If I open Google Maps it shows the overlay. 

I only want it to be active when Navigation is active and in focus.

How would one do this?

Bob Hansen

unread,
Oct 22, 2013, 10:45:47 PM10/22/13
to tas...@googlegroups.com
Try using Tasker's %WIN variable. This variable contains the name of the currently visible window. In the case of the Navigation app, the %WIN variable will contain, appropriately enough, Navigation. So,

If %WIN ~ Navigation
< do what ever >
Endif

or if you're need to check as part of a context, use

Context > State > Variable Value: %WIN  Op: ~ Value: Navigation

Vernon Gibson

unread,
Oct 23, 2013, 12:11:26 AM10/23/13
to tas...@googlegroups.com
This does not seem to be working for me. To test I setup a profile with the context as described and made a new task that would simply create a popup notification with the %WIN variable as its text but no dice. I've checked my spelling, and everything else I can think of but can't seem to get it to work. 

Joseph Richman

unread,
Oct 23, 2013, 12:15:59 AM10/23/13
to tas...@googlegroups.com
This is a good idea that I wouldn't have otherwise thought of. Allows you to put useful information over a map that's normally not so useful.


On Tuesday, October 22, 2013 7:32:10 PM UTC-7, Vernon Gibson wrote:

Joseph Richman

unread,
Oct 23, 2013, 12:22:46 AM10/23/13
to tas...@googlegroups.com
Turns out the new "Navigation" has a %WIN of Maps meaning there's no way to dictate whether the app is just maps or actually Navigation.


On Tuesday, October 22, 2013 7:32:10 PM UTC-7, Vernon Gibson wrote:

Vernon Gibson

unread,
Oct 23, 2013, 12:23:20 AM10/23/13
to tas...@googlegroups.com
Yeah.... The thing is my car's speedo is for whatever reason not accurate and a lot of the time I use the iBolt car home app which shows speed and has buttons... but, about the only time I even dock my phone in the car is when I want to use it for navigation purposes... Thus the reason I'm trying to get this working and I intend to share it once I get it working as I want and then figure out the best way to share it lol... I'm what I would consider still fairly new to Tasker but its very programmatic which works for me since I am a coder. Still learning the qwerks and tricks to getting it to do my bidding though.

Joseph Richman

unread,
Oct 23, 2013, 12:29:26 AM10/23/13
to tas...@googlegroups.com
What you could do since your nav should be up and nothing else while driving, just detect when you're moving at speeds greater than like 10MpH and tell it to put up the overlay. Until we can find a better way at least.

Vernon Gibson

unread,
Oct 23, 2013, 12:33:47 AM10/23/13
to tas...@googlegroups.com
I knew when they changed the app to roll Maps and Navigation into the same app it would be a problem... I didn't know why at the time but I just knew... lol

Hopefully a better way can be found but for now I will just have to get a little more convoluted with the context to initialize the overlay.

Joseph Richman

unread,
Oct 23, 2013, 12:53:59 AM10/23/13
to tas...@googlegroups.com
AutoNotification set it to detect the notification from maps make sure that expanded notification texts contains "Exit Navigation" then when "Maps" window is up do the overlay.

Joseph Richman

unread,
Oct 23, 2013, 1:12:52 AM10/23/13
to tas...@googlegroups.com
There's no way to actual way to compare expanded text it would seem, but you can just do two contexts.

AutoNotification Intercept Notification Created App Maps
Value matches Maps

That should give you a somewhat decent trigger but the "persistent" notification continually gets recreated so it'd be best to have the task destroy the scene and then recreate it.

Joseph Richman

unread,
Oct 23, 2013, 2:17:14 AM10/23/13
to tas...@googlegroups.com
So I threw together a quick little version for myself. 

I'm using Notification Intercept to detect the Navigation Notification then checking if Maps is up using %WIN. It's not perfect but it works. 


I'm then using two additional profiles one to destroy the scene if the window isn't Maps and another to destroy it if the Navigation Notification is canceled. This will make it so the scene gets destroyed if you leave maps or if you're in maps and cancel navigation. However if you get to maps and navigation is still running but it's not on the navigation page (sometimes this happens to me) the overlay will be there.

The problem currently is if you're switching between apps then when you switch back to Maps it won't bring the overlay back up until the Nav Notification recreates itself. Which usually only takes a minute. The alternative is to restart nav to force it to bring it up.

I've designed the scene so it sits in the bottom part of the screen where Navigation shows the Time Remaining/ETA/Miles Left and am using a scene size so it overlays perfectly without covering the settings button the exit nav button or the map. Then I made scene background invisible so with the right tweaking it might be possible to get the overlay to look as if it's built into maps.

Rich D

unread,
Oct 23, 2013, 5:49:04 AM10/23/13
to tas...@googlegroups.com

> This does not seem to be working for me. To test I setup a profile with the context as described and made a new task that would simply create a popup notification with the %WIN variable as its text but no dice. I've checked my spelling, and everything else I can think of but can't seem to get it to work. 
>

Do you mean you can't get a value for %WIN or that the value is always "maps" when you are in navigation?

For %WIN To work you need to select tasker and your Android accessibility settings..

In reference to detecting when you are in the navigation only A couple possible workaround would be..

1. If your phone is always docked  when you're navigating you could check the orientation In combination with the window value. 

2. You could use a tasker widget for taskcut to always start your navigation you wouldn't know you wanted navigation and not maps. 

Joseph Richman

unread,
Oct 23, 2013, 8:51:48 AM10/23/13
to tas...@googlegroups.com
Due to the merging of Navigation and Maps you can't use %WIN to detect Navigation as it all appears to be Maps. My solution works around the issues as best as possible.

Vernon Gibson

unread,
Oct 23, 2013, 9:28:18 AM10/23/13
to tas...@googlegroups.com

Can you explain how your setting up the Notification Intercept? I seem to be having trouble getting that sorted.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/NaOxiaDUb9g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.

Bob Hansen

unread,
Oct 23, 2013, 10:01:13 AM10/23/13
to tas...@googlegroups.com
Do you have Tasker enabled (on) in android settings Accessibility - services? Its required.

Vernon Gibson

unread,
Oct 23, 2013, 10:05:01 AM10/23/13
to tas...@googlegroups.com

The one called Tasker JB?
If so then yes.

Screenshot_2013-10-23-09-02-08.png

Vernon Gibson

unread,
Oct 23, 2013, 11:51:18 AM10/23/13
to tas...@googlegroups.com

Ok, out of frustration trying to figure out why setting a context for %WIN~A Maps was not working I setup a scene with a button to create a pop up with the current %WIN value. But, it seems it only ever shows "Force Stop"... This does not seem like expected behavior.

micha...@gmail.com

unread,
Oct 23, 2013, 12:51:40 PM10/23/13
to tas...@googlegroups.com

I'd be interested in seeing how you coded the speedometer to play nicely with Maps. 
 
 I had wanted to do the same thing and was able to get it working, but it messes up the map auto-scroll; instead of scrolling smoothly, it goes in fits and starts, only updating every second or so.  I'm updating the speedo about every 3/4 of a second and the map seems to update during the pauses. 
 
 I assume it's because of the way I'm grabbing the GPS data, but I haven't figured out a less intensive way of doing it.

Joseph Richman

unread,
Oct 23, 2013, 2:00:59 PM10/23/13
to tas...@googlegroups.com
I haven't tested my version yet 

My overlay is just another profile to convert to MPH and then a scene.

If LOCSPD set Set Variable %MPH to %LOCSPD * 2.23694 (Do Math)
Then using AutoNotification's Latest Beta for all the triggers mentioned above on 4.3 to pop up the overlay then have the overlay show %MPH.

Tasker shouldn't be doing any of it's own GPS grabbing since Maps should be doing it anyways.

I'll test it here in the next hour and if it all works smoothly I'll put together a more comprehensive guide on how to do it.

Vernon Gibson

unread,
Oct 23, 2013, 3:04:49 PM10/23/13
to tas...@googlegroups.com
Sounds similar to what I have set up. It uses multiple profiles and tasks right now to keep things easier for me to track. But, workout the functions to only show the Overlay while navigation is open (since I've yet to get that to work) here is what I use.

--------------------

Profile: Car Settings (5)
State: Docked [ Type:Desk ]
Enter: Load Car Settings (6)
A1: Vibrate [ Time:200 ]
A2: Variable Set [ Name:%mediaVolume To:%VOLM Do Maths:Off Append:Off ]
A3: Media Volume [ Level:12 Display:Off Sound:Off ]
A4: Display Timeout [ Secs:* Mins:* Hours:* ]
A5: WiFi [ Set:Off ]
A6: Secure Settings [ Configuration:GPS Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A7: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ]
A8: Load App [ App:Maps Data: Exclude From Recent Apps:Off ]
A9: Profile Status [ Name:Navigation Overlay Set:On ]
A10: Say [ Text:Car settings loaded! Engine:Voice:default:default Stream:1 Pitch:5 Speed:5 Continue Task Immediately:Off ]

Exit: Unload Car Settings (21)
A1: Vibrate Pattern [ Pattern:0, 100, 25, 100 ]
A2: Kill App [ App:Maps Use Root:On ]
A3: Display Timeout [ Secs:30 Mins:0 Hours:0 ]
A4: WiFi [ Set:On ]
A5: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A6: Secure Settings [ Configuration:GPS Disabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A7: Media Volume [ Level:%mediaVolume Display:Off Sound:Off ]
A8: Say [ Text:Car settings unloaded! Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Continue Task Immediately:Off ]


Then here are the sub profiles that control the needed tasks.


--------------------

Profile: Navigation Overlay (22)
State: Profile Active [ Name:Car Settings ]
Enter: Load Nav Overlay (16)
A1: Show Scene [ Name:Navigation Overlay Display As:Overlay Horizontal Position:100 Vertical Position:100 Show Exit Button:Off Continue Task Immediately:On ]
A2: Profile Status [ Name:Nav Overlay Colorator Set:On ]
A3: Profile Status [ Name:Nav Overlay Speed Updater Set:On ]

Exit: Unload Nav Overlay (17)
A1: Profile Status [ Name:Nav Overlay Speed Updater Set:Off ]
A2: Profile Status [ Name:Nav Overlay Colorator Set:Off ]
A3: Destroy Scene [ Name:Navigation Overlay ]
A4: Profile Status [ Name:Navigation Overlay Set:Off ]

--------------------

Profile: Nav Overlay Speed Updater (9)
State: Profile Active [ Name:Car Settings ]
Enter: Nav Overlay Speed Updater (10)
A1: Variable Set [ Name:%MPH To:%LOCSPD * 2.2369 Do Maths:On Append:Off ]
A2: Variable Split [ Name:%MPH Splitter:. Delete Base:Off ]
A3: Element Text [ Scene Name:Navigation Overlay Element:Text1 Position:Replace Existing Text:%MPH1 mph ]
A4: Wait [ MS:1 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A5: [X] Goto [ Type:Action Number Number:2 Label: ]
A6: [X] Stop [ With Error:Off Task:Nav Overlay Speed Updater ]


And, because of night mode for Navigation I have a profile for changing the color of the text in the scene.

--------------------

Profile: Nav Overlay Colorator (23)
State: Light Level [ From:0 To:0 ]
Enter: Nav Overlay Colorator (18)
A1: Element Text Colour [ Scene Name:Navigation Overlay Element:Text1 Colour:#FF00FF00 ]

Exit: Nav Overlay De-Colorator (19)
A1: Element Text Colour [ Scene Name:Navigation Overlay Element:Text1 Colour:#FF000000 ]

--------------------

Scene: Navigation Overlay
P:719x1279 L:1271x719
Element: Text1/Text
Geometry:
P:488,1079 208x79 L:904,619 220x99
Content:
Text: 0 mph
Text Size: 24
Text Width Scale Percent: 100
Text Colour: #000000
Position: Centre
Vertical Fit Mode: None
Text Format: Plain Text


Hope the above makes sense. Not sure of the best method to share things.

Vernon Gibson

unread,
Oct 23, 2013, 3:08:23 PM10/23/13
to tas...@googlegroups.com
Spotted a bug I forgot to fix in the speed update task. GoTo should go back to 1... Not 2.

Forgot I removed something previously today.

Vernon Gibson

unread,
Oct 23, 2013, 5:20:18 PM10/23/13
to tas...@googlegroups.com
oh, really unsure what I did to get it working but I stumbled into making it work for seeing the %WIN var for "Maps"... Now, I just need to get it also validating against the "Navigation" notification. 

Once I get the notification capture working so it only works when in Navigation and get media buttons added for play/pause/skip I will be a happy camper! and, I'll share too :)

Brandon Horwath

unread,
Oct 23, 2013, 10:02:22 PM10/23/13
to tas...@googlegroups.com
... until the next update XD

Joseph Richman

unread,
Oct 25, 2013, 5:38:02 AM10/25/13
to tas...@googlegroups.com
I've perfected the triggering it part here:

Profile: Navigation Overlay (51)
State: AutoNotification Intercept [ Configuration:Notification Type: Only Created Notifications
Notification App: Maps
Persistent: true ]
State: Variable Value [ Name:%WIN Op:Matches Value:Maps ]
Enter: Anon (52)
A1: Flash [ Text:Navigation Running Long:Off ] 
A2: Show Scene [ Name:Map MpH Overlay Display As:Overlay Horizontal Position:185 Vertical Position:200 Animation:System Show Exit Button:Off Continue Task Immediately:On ] 
A3: Show Scene [ Name:Map Media Overlay Display As:Overlay, Blocking Horizontal Position:21 Vertical Position:200 Animation:System Show Exit Button:Off Continue Task Immediately:On ] 

My issue was I couldn't get the overlay to update, but I'm going to try the code you shared to get it working.

The other issue was I couldn't get the media buttons working using the Media Control action even if the music was already playing.

Also you'll have to create two separate profiles to destroy scenes. One if %WIN != Maps    another if the Notification gets canceled. This way they don't show up in maps unless navigation is running. Also if navigation is running but window isn't Maps it'll destroy them too.


On Tuesday, October 22, 2013 7:32:10 PM UTC-7, Vernon Gibson wrote:

Vernon Gibson

unread,
Oct 25, 2013, 10:13:18 AM10/25/13
to tas...@googlegroups.com

I think I just found out that there is no way for me to intercept the notification because I'm not on Android 4.3 :-(

--

Joseph Richman

unread,
Oct 25, 2013, 2:49:20 PM10/25/13
to tas...@googlegroups.com
Nope without 4.3 native intercepting doesn't exist, and I was never able to find a good way to detect notifications. You could always go the custom rom route, or hope that 4.4 is released to your device in the near future.

Vernon Gibson

unread,
Oct 25, 2013, 3:06:08 PM10/25/13
to tas...@googlegroups.com

Samsung is claiming an update to the S3 and Note 2 are imminent but I'm on TMo, so I'll believe it when it happens. I'm already on a custom rom though. Tweaked 2.5, but its built on 4.1.2... I like it cause its mostly stock, minus the bloatware from TMo and still has TouchWiz and stylus support.

Joseph Richman

unread,
Oct 25, 2013, 4:20:05 PM10/25/13
to tas...@googlegroups.com
An AOSP 4.3 version might suit you nicely if one exists for your phone. Gives you just stock android.

Daniel Dur

unread,
Feb 21, 2014, 7:21:13 AM2/21/14
to tas...@googlegroups.com
I've had something similar to this working on my Galaxy Nexus with CM10.2 (Android 4.3). But my phone broke and after it got fixed, I had to remake everything from scratch (this time on CM11).

Problem is that now the speed update doesn't work. The task runs once an it stops and the speed is only updated once, when the scene is displayed.

Any idea what could have gone wrong?

Thanks!

Here are my profiles:

Profile: waze_speed (19)
Application: Waze
Enter: waze.speed (22)
A1: Get Location [ Source:GPS Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:On Continue Task After Error:On ]
A2: Show Scene [ Name:speed.waze Display As:Overlay Horizontal Position:185 Vertical Position:15 Animation:System Show Exit Button:Off Continue Task Immediately:On ]
A3: Profile Status [ Name:speed_update Set:On ]

Exit: no.speed (20)
A1: Destroy Scene [ Name:speed.maps ]
A2: Destroy Scene [ Name:speed.waze ]
A3: Profile Status [ Name:speed_update Set:Off ]

Profile: speed_update (17)
Priority: 7
State: Profile Active [ Name:waze_speed ]
Enter: speed.update (18)
<update>
A1: Variable Set [ Name:%Speed To:%LOCSPD * 3.6 Do Maths:On Append:Off ]
A2: Variable Split [ Name:%Speed Splitter:. Delete Base:Off ]
A3: Element Text [ Scene Name:speed.maps Element:Speed Position:Replace Existing Text:%Speed1 ]
A4: Element Text [ Scene Name:speed.waze Element:Speed Position:Replace Existing Text:%Speed1 ]
A5: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A6: Goto [ Type:Action Number Number:1 Label:update ]

Chris Brown

unread,
Jun 12, 2014, 2:07:35 AM6/12/14
to tas...@googlegroups.com
Has anyone figured out how to hide the scene upon pulling up the textual direction list?
Reply all
Reply to author
Forward
0 new messages