⚡️ How to lock an Android phone when pocketed: a Tasker recipe

During the last few months I have noticed that I've sent a number of messages and also changed some system settings unintentionally, all while trying to pocket my phone unlocked. Not something pleasant. And, to my surprise, there was no built-in setting for detecting owner's pocket. Thanks to Android's flexibility, we can develop our own.

Below you may find a working recipe for Tasker. Please be aware of the following caveats:

Step 1: isolate Google Phone (or any other dialer app) and maybe some of your fav games

In order to prevent unexpected hanging up, or locking the screen when gaming, isolate selected apps with a special profile:

  1. Create a task that sets any variable of your choice to true. Let's say we use %donotlock variable
  2. Create another task that unsets this variable
  3. Create a profile with Applications conditional
  4. Pick applications that you would like to isolate
  5. Select a task that sets the %donotlock variable to true
  6. Long tap on tasks assigned to you new profile to add an exit task that unsets the variable
See pictures for more details

Step 1.1

Step 1.2

Step 1.4

Steps 1.5 and 1.6

Step 2: Install Pineapple Lock Screen

  1. Get the app from f-droid
  2. Launch the app
  3. Grant all required permissions (Accessibility)
  4. Test the screen lock functionality
See pictures for more details

The lock screen app

Required permissions

Step 3: Create a Tasker task that triggers Pineapple Lock Screen

  1. Create a new task
  2. Add a "Wait" step for convenience, I usually pick one second delay
  3. Add an Application step, long tap on "Pineapple Lock Screen", select the Lock Screen shortcut of the app
    1. Add a conditional that prevents this step from executing when %donotlock variable is set
See pictures for more details

Steps 3.1 and 3.2

Steps 3.3 and 3.3.1

Step 4: Assign a profile to your newly created task

  1. Create a new profile
  2. Select State -> Sensor -> Proximity Sensor
  3. Assign your newly created task from step 3
  4. You're ready to go!
See pictures for more details

The end result

With this relatively small recipe I've gained confidence in me not making any accidental butt calls when tucking away my phone in haste while checking out at supermarket. Hope it helps you too!

Wed, 12 Jul 2023 12:36:38 +0200

RSS // Telegram // Статистика