停止屏幕锁定时,电源按钮是pressed [英] Stop the Screen Locking when power button is pressed

查看:156
本文介绍了停止屏幕锁定时,电源按钮是pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  覆盖在电源键的Andr​​oid

有没有我可以停止屏幕任何可能的方式被锁定时,电源按钮是pressed。

Is there any possible way I can stop the screen being locked when the power button is pressed.

推荐答案

您不能停止屏幕,以获取锁(短按一下),但你可以得到的电源键的长按键preSS事件。

You can't stop screen to get lock(short click), But you can get the event of long keypress of Power button

 @Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
        //dostuff
        return true;
    }

    return super.dispatchKeyEvent(event);
}

这篇关于停止屏幕锁定时,电源按钮是pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆