• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Using tasker to simulate power button

Search This thread

snorrski

Member
Nov 12, 2013
34
10
Copenhagen
I want to use tasker to turn the screen off. Secure Settings > Lock Device forces me to use pin, which is not what I want, as I use a finger print scanner to wake my device. Shell > Input keyevent 26 does not work either, as I am not rooted (Huawei Mate 9 pro, doesn't seem to have a reliable root yet).

I have tried doing it with System > Send intent, but that seems to have no effect. I dont know if I am doing it wrong. I have also tried
Code:
terminal task
, with a code like this (and some variants of it), without success:

Code:
am start --user 0 -a android.intent.extra.KEY_EVENT --es KEYCODE_POWER ACTION_DOWN

I have also tinkered with

Code:
android.intent.action.SCREEN_OFF
...but with even less success.

Any ideas as how how I can get this to work? Either with terminal emulator or tasker send intent task?
 
Last edited:

R4V3N-2010

Senior Member
Dec 26, 2014
163
311
Dals Långed
I think you can't do that cause you're using your Fingerprint. That is a security future and Tasker can't bypass it. Don't nail me on it cause I am not sure. Maybe someone else can prove me wrong.

Sent from my ONEPLUS A3003 using Tapatalk
 

digitalpig82

Senior Member
Oct 20, 2014
214
118
Berlin
Maybe you could setup a workaround for this. For example, you could lower the display timeout value to one second so your device locks itself.
(Don't forget to change the timeout back to your preferred value after another second!)
 

snorrski

Member
Nov 12, 2013
34
10
Copenhagen
I found a way to do it:
1: Create a task:
display > display timeout: 8 seconds
scene: Show scene: popup - display as overlay, blocking, full screen​
2: create a profile for screen on, create task:
hide scene: popup
display > display timeout: 30 seconds​
 

digitalpig82

Senior Member
Oct 20, 2014
214
118
Berlin
So you're hiding the ui with a black screen until the screen is really switched off after 8 seconds, right? But what happens when you press the back or home button within the 8 seconds? Does the scene disappear?
 

greyhd

Senior Member
Apr 27, 2012
1,840
661
This is what I do. Just make a task with Run shell, no need for security settings app. In the command line type input keyevent 26. You then can add a short cut when you double tap the homescreen to turn off the screen.
 
  • Like
Reactions: umetnic

snorrski

Member
Nov 12, 2013
34
10
Copenhagen
  • Like
Reactions: GrippingSphere

deepesh_p

Senior Member
Jan 14, 2014
151
35
@snorrski you might want to have a look at this:

https://forum.xda-developers.com/u/...-adb-shell-t3562013/post72212441#post72212441

It seems to be exactly what you wanted. It works without root and on my (unrooted) S7 Edge, I can still use the fingerprint sensor to unlock my device after locking it this way (input keyevent POWER). :cowboy:

@snorrski
I know it's been over 2 years since y'all had this discussion, but I hope this still reaches you.

The power button on my Mi A1 stopped working recently and I can't seem to find it's replacement flex cable anywhere. I'm entirely new to Tasker but I have been reading for hours now to find ways to use a screen based interaction (say a double tap on the screen) to simulate the Power button to turn the screen off while still being able to unlock my phone with my fingerprint scanner.

So far, I've understood that it is doable (with an article refering to input keyevent 26), even more so on Android Pie (with another article refering to using Global_Actions) than it was previously possible, but am entirely clueless on how. I also couldn't quite understand the process of using the remote ADB shell plugin you mention here.

Could either of the two of you please share a step-by-step how-to on how to achieve the same? It would really help a lot. Thank you :)

Note: I'm using unrooted Mi A1 running stock Android Pie with July 1st security patch.
 

ktmom

Retired Forum Moderator
Apr 22, 2015
5,186
3,380
Deep Space Station K7
@snorrski
I know it's been over 2 years since y'all had this discussion, but I hope this still reaches you.

The power button on my Mi A1 stopped working recently and I can't seem to find it's replacement flex cable anywhere. I'm entirely new to Tasker but I have been reading for hours now to find ways to use a screen based interaction (say a double tap on the screen) to simulate the Power button to turn the screen off while still being able to unlock my phone with my fingerprint scanner.

So far, I've understood that it is doable (with an article refering to input keyevent 26), even more so on Android Pie (with another article refering to using Global_Actions) than it was previously possible, but am entirely clueless on how. I also couldn't quite understand the process of using the remote ADB shell plugin you mention here.

Could either of the two of you please share a step-by-step how-to on how to achieve the same? It would really help a lot. Thank you :)

Note: I'm using unrooted Mi A1 running stock Android Pie with July 1st security patch.
Your post is getting long in the tooth. Are you still looking for help?

There are button remapping apps and apps that do double tap for off in the play store. Also, launchers can do this. Nova launcher for sure, but others I believe as well.
 
  • Like
Reactions: deepesh_p

deepesh_p

Senior Member
Jan 14, 2014
151
35
Your post is getting long in the tooth. Are you still looking for help?

There are button remapping apps and apps that do double tap for off in the play store. Also, launchers can do this. Nova launcher for sure, but others I believe as well.

Hey, thanks for the suggestions. Gravity Screen, Nova Launcher as well as finally being able to understand Tasker, did help solve this issue, as I still look for a flex cable to fix the physical button issue as well.
 

deepesh_p

Senior Member
Jan 14, 2014
151
35

ktmom

Retired Forum Moderator
Apr 22, 2015
5,186
3,380
Deep Space Station K7

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    @snorrski you might want to have a look at this:

    https://forum.xda-developers.com/u/...-adb-shell-t3562013/post72212441#post72212441

    It seems to be exactly what you wanted. It works without root and on my (unrooted) S7 Edge, I can still use the fingerprint sensor to unlock my device after locking it this way (input keyevent POWER). :cowboy:
    1
    This is what I do. Just make a task with Run shell, no need for security settings app. In the command line type input keyevent 26. You then can add a short cut when you double tap the homescreen to turn off the screen.
    1
    @snorrski you might want to have a look at this:

    https://forum.xda-developers.com/u/...-adb-shell-t3562013/post72212441#post72212441

    It seems to be exactly what you wanted. It works without root and on my (unrooted) S7 Edge, I can still use the fingerprint sensor to unlock my device after locking it this way (input keyevent POWER). :cowboy:
    Thank you! That does indeed look like what I need!
    1
    @snorrski
    I know it's been over 2 years since y'all had this discussion, but I hope this still reaches you.

    The power button on my Mi A1 stopped working recently and I can't seem to find it's replacement flex cable anywhere. I'm entirely new to Tasker but I have been reading for hours now to find ways to use a screen based interaction (say a double tap on the screen) to simulate the Power button to turn the screen off while still being able to unlock my phone with my fingerprint scanner.

    So far, I've understood that it is doable (with an article refering to input keyevent 26), even more so on Android Pie (with another article refering to using Global_Actions) than it was previously possible, but am entirely clueless on how. I also couldn't quite understand the process of using the remote ADB shell plugin you mention here.

    Could either of the two of you please share a step-by-step how-to on how to achieve the same? It would really help a lot. Thank you :)

    Note: I'm using unrooted Mi A1 running stock Android Pie with July 1st security patch.
    Your post is getting long in the tooth. Are you still looking for help?

    There are button remapping apps and apps that do double tap for off in the play store. Also, launchers can do this. Nova launcher for sure, but others I believe as well.