Android的 - 如何prevent转动时音量或相机关键是pressed手机屏幕? [英] Android - How to prevent the phone screen from turning on when volume or camera key is pressed?

查看:85
本文介绍了Android的 - 如何prevent转动时音量或相机关键是pressed手机屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动,显示了当手机屏幕进入睡眠/关机即变成黑色。 出于某种原因,在电话接通时,音量按钮或相机按钮是pressed。通过导通,我指的是屏幕唤醒或回来在黑屏状态。

I have an activity that shows up when the phone screen goes to sleep/turns off ie turns black. For some reason, the phone turns on when the volume buttons or the camera buttons are pressed. By turns on, I mean the screen wakes up or comes back from the black screen state.

我已经使用dispatchKeyEvent(KeyEvent的事件)尝试和按钮都在活动的残疾人,但他们仍然清醒过来的电话。

I've tried using dispatchKeyEvent(KeyEvent event) and the buttons are disabled on the activity, but they still wake up the phone.

推荐答案

您可以尝试重写的onkeydown(KeyEvent的)方法,并改变这些密钥会发生什么。不过,我不是太乐观,如果你正在运行的活动,这将是处于非活动状态时,显示屏关闭,并且也可能是手机硬连接到这些按钮上醒来。这可能是特定的设备。很难说。尝试了这一点,让我知道如何去,我currious

You could try overriding the onKeyDown(KeyEvent) method and change what happens for those keys. However, I'm not too optimistic as if you're running an activity, it will be in an inactive state when the display is off, and also it could be that the phone is hard wired to wake up on those buttons. It could be device specific. Hard to say. Try that out and let me know how it goes, I'm currious

这篇关于Android的 - 如何prevent转动时音量或相机关键是pressed手机屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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