Google Ads

Automatically turn on GPS when Waze is running (even when Waze is running in background)


This Tasker profile will automatically turn on my Android device GPS setting whenever Waze is running. I have tweak the Tasker code a little to enable the GPS to remain turned on when Waze is running in the background. This will enable you to receive calls or do other things when Waze is running background without worrying the GPS gets turned off. Apart from Tasker, you will need a rooted Android, "Secure Settings" and "Busy Box" to be installed. 

Important notes about Secure Settings

In Secure Settings, use Run Command for the action. Use this command to query the state of the Waze app running in the background:
cat /proc/$(pgrep com.waze)/oom_adj
Check the Output Variable and use "%WAZE_RUN" as the output variable name.
Check the Exit Code variable and use "%CMD_EXIT" as the exit code variable name.

Note: Make sure you install BusyBox as you will need the "pgrep" program to get the process id of Waze app.

Tasker Recipe

Profile: Waze Mode (15)
Application: Waze
Enter: Waze Settings Start (16)
A1: Media Volume [ Level:15 Display:Off Sound:Off ]
A2: GPS [ Set:On ]
Exit: Waze Settings Exit (18)
A1: Variable Clear [ Name: Pattern Matching:Off ]
A2: Secure Settings [ Configuration:Check Waze Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A3: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A4: If [ %CMD_EXIT = 0 ]
A5: If [ %WAZE_RUN < 3 ]
A6: GPS [ Set:On ]
A7: [X] Flash [ Text:%WAZE_RUN Long:Off ]
A8: Flash [ Text:GPS Enabled Long:On ]
A9: Else
A10: GPS [ Set:Off ]
A11: [X] Flash [ Text:%WAZE_RUN Long:Off ]
A12: Flash [ Text:GPS Disabled Long:On ]
A13: End If
A14: Else
A15: GPS [ Set:Off ]
A16: [X] Flash [ Text:%WAZE_RUN Long:Off ]
A17: Flash [ Text:GPS Disabled Long:On ]
A18: End If




Comments

  1. Thanks so much! Wanted something that did exactly this for a while.

    ReplyDelete
    Replies
    1. Can this same method be used for other apps that use gps?

      Delete
    2. what would I have to change to apply this to another app for example google maps?

      Delete
    3. Yes, you can use the same method for other apps. You need to replace "com.waze". You will need to find out what is the process name for google maps or your intended apps. Use the busy box and terminal commands to find out.

      Delete
  2. Hi Boon Seong, can't download the profile, site is down I think, able to re upload?

    ReplyDelete
    Replies
    1. Hello Johnson, I can still access the download.

      Delete
    2. Hi Boon Seong, yeah it's okie now. Thx!

      Delete
  3. Since you are not using a Profile>State (e.g. Bluetooth connected) to trigger launching/killing waze and turning GPS On/Off you are trying to make the GPS mode dependent on Waze running. To me that is not necessary since obviously you are anyway launching and shutting down Waze manually. If so, I suggest two tasks that will accomplish everything we need here.

    Task A (Waze On):
    1. Turn on GPS.
    2. Launch Waze.
    3. Notify. (Title: “Waze is Running”, Click Permanent and give it Priority 5) Add an action to perform Task B (Waze Off) Give it a label “Shut Down” and you can even add a power icon.

    Now you have a new Notification that looks exactly the same as Waze’s native one. But since you don’t want two notifications (Yours from Tasker + Waze’s Native one) get rid of the native one. (I accomplished this using Garvity Box’s “Ongoing Notification Blocker”). You might be able to this from Tasker but I could find the title of Waze’s native notification in order to cancel, plus I have a feeling it will keep trying to come back)

    Next setup Task B (Waze Off):
    1. Turn GPS Off
    2. Kill waze
    3. Notify Cancel (make sure the title matches the one used in Task A “Waze is Running”)

    Next make a Tasker shortcut to Task A (Waze On) and use the Waze application Icon. Now you have an icon on your homescreen that looks exactly like Waze but will accomplish much more. Use this to launch Waze every time. When you want to shutdown use the “shutdown button” in the notification you created as you usually would to close Waze but now it will not only close Waze it will also Turn GPS off. Obviously you can add more tasks to A and B such as read out texts etc.

    A little Background: I used to use a toggle widget to do all of this but getting back to the toggle was a pain so I was trying to find ways to add the toggle button to the status bar for quick access. Problem was a) I didn’t like the options on the market (like Power Toggles) and b) why do I need the toggle in the status bar all the time if I can have the button there only when I need it? I actually use this method for various other tasks instead of toggles like Night Mode and much more!

    ReplyDelete
  4. That is the first solution that is working for me at all. But I have a smaller problem... Often I get an error, when a different app is running. Secure Settings then gives me a ".../proc//oom_adj... no such file or directory". If I start that app im checking for it's okay again. Any idea how I can handle that matter?

    ReplyDelete
  5. This was working for me for a while but has stopped working after updating to Android 5.0.1. As far as I can tell, secure settings is receiving the exit command when waze moves to the background and is thus shutting down GPS. Has anyone else had this issue?

    ReplyDelete
  6. The Dropbox link to the tasker profile seems to be dead, could you please update it?

    ReplyDelete

Post a Comment

Thank you for visiting Almost a Technocrat. Due to many spam comments, your comment will be moderated.

Popular posts from this blog

A Better SKMEI 1358 Instructions Manual

A Better SKMEI 1418 / 1427 Instructions Manual

How to force stop or cancel Android download manager downloading process

SKMEI 1358 Review