简体   繁体   中英

How to simulate a click on the power button in Android Tv?

I want to write a small application so that when it starts, it starts counting for 100 seconds and then simulates a click on the power button. To send the device to sleep. How to simulate a click on the power button in Android Tv? Thanks for advance

Android TV (Android 8)

I cannot comment only can reply. but I want you to try this first. I will update later soon.

KeyEvent.KEYCODE_POWER.performClick();

please reply if this doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM