How to use Tasker to enable locking your screen with Google Assistant

By | January 15, 2023

Ever since I started being able to talk to my Android phone, I’ve wanted to be able to tell it to lock my screen. And ever since then, Google Assistant has stubbornly refused to do it. I can’t imagine why Google hasn’t implemented this feature; they obviously know people want it, since when you ask Assistant to lock your screen it recognizes the request and tells you it can’t.

Today, however, I realized that with this, as with so many other things that Android doesn’t have built into it but should, I can bridge the gap with Tasker. Tasker is an incredibly flexible Android automation app which I’ve used to automate many things over the years.

Here’s how to use Tasker to allow you to lock your screen with your voice, and how to avoid the various gotchas I ran into while figuring this out.

I am assuming here that you have basic familiarity with Tasker, if not, go and learn, and come back when you’re ready to proceed.

Tasker has a Google Assistant integration built in. Basically, you can say “OK Google, run task name in Tasker”, and Google will tell Tasker to run the task with that name. See the documentation for more details. However, there are two gotchas:

  1. It doesn’t always work when the Tasker app or Assistant is already open when you try to use it. Make sure you’re on your home screen or in a different app.
  2. Sometimes the name of a task can confuse Assistant into doing something other than sending the task to Tasker. To avoid this, you can give the task a silly name that Assistant won’t confuse with another action. As I explain below, you won’t actually have to say that silly name to activate the task, though you can if you want.

The first thing to do is create a task in Tasker called “Stroganoff” containing the “Display / Turn Off” action with the “Lock” checkbox enabled.

After doing that, tapping the check-mark to activate the changes, and returning to your home screen (because of the gotcha mentioned above), you can say “Hey Google, run Stroganoff in Tasker” and your screen will lock. Mission accomplished!

However, let’s be a bit more clever and set up a “routine” in Assistant so you can use more intuitive phrases to lock the screen. Here’s how to do that:

  1. Open the Google app, tap your avatar and select “Settings”, “Google Assistant”, and then “Routines”.
  2. Tap “New” to create a new routine.
  3. Tap “Personal”.
  4. Tap “Add starter”.
  5. Tap “When I say to Google Assistant”.
  6. Add all these phrases: “Screen off”, “Turn off my screen”, “Lock my screen”, “Turn my screen off”, “Lock screen”.
  7. Tap “Add action”.
  8. Tap “Try adding your own”.
  9. Enter “run Stroganoff in Tasker” in the text box.
  10. Save everything.

That should do it! If you say “OK Google” or “Hey Google” followed by any of the phrases above, your screen should lock.

Share and enjoy!

Print Friendly, PDF & Email
Share

2 thoughts on “How to use Tasker to enable locking your screen with Google Assistant

  1. Anonymous

    how can I get this to work if the screen is off? I can’t get Google assistant to run a Tasker task if the screen is off

    Reply
    1. jik Post author

      Doesn’t your screen turn on when you say “Ok Google” or “Hey Google” at the start of the command?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *