通话期间禁用光传感器 - Android
当您在 Android 中打电话时,光传感器正在工作。 如果遮住屏幕的左上角,显示屏会变黑,您将看不到任何内容。
我想取消该功能,并尝试使用 Android 传感器< /a> 和 光传感器 但它不工作。
这是我的代码:
senMgrLight=(SensorManager)getSystemService(Context.SENSOR_SERVICE);
senMgrLight.registerListener(onSensorListener,
senMgrLight.getDefaultSensor(Sensor.TYPE_LIGHT),
SensorManager.SENSOR_DELAY_FASTEST);
谢谢。
When you talk on the phone in Android the light sensor is working.
If you cover the top left corner of the screen, the display turns black and you can't see anything.
I would like to cancel that feature and I tried working with Android Sensors and the Light Sensor but it is not working.
This is my code:
senMgrLight=(SensorManager)getSystemService(Context.SENSOR_SERVICE);
senMgrLight.registerListener(onSensorListener,
senMgrLight.getDefaultSensor(Sensor.TYPE_LIGHT),
SensorManager.SENSOR_DELAY_FASTEST);
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用的传感器是接近传感器,
试试这个,这会让您知道传感器是否隐藏(并且它在您通话时工作)
The sensor you need to work with is the proximity sensor,
try this, this will let you know if the sensor is hidden or not (and it works while your on a call)
我会使用类
Settings.System
阅读SCREEN_BRIGHTNESS
和SCREEN_BRIGHTNESS_MODE
在调用之前通过 getInt()。然后我将通过 setInt() 设置新值,即亮度 255 和SCREEN_BRIGHTNESS_MODE_MANUAL
模式 - 应以最大量提供恒定亮度。通话挂断后,您可以恢复在通过 setInt() 更改值之前存储的旧值,以便用户恢复其初始设置。 :-)
不要忘记该模式仅适用于 Android 2.2 及更高版本(API 级别 8),因此如果您也想针对较旧的 Android 版本,则必须使用反射。当然,您肯定需要写入系统设置的权限。
I would use the class
Settings.System
to read theSCREEN_BRIGHTNESS
and theSCREEN_BRIGHTNESS_MODE
via getInt() before a call is made. Then I would set new values via setInt(), namely 255 for the brightness andSCREEN_BRIGHTNESS_MODE_MANUAL
for the mode - which should give constant brightness at maximum amount.After the call is hung up you can restore the old values you stored before changing the values via setInt() so the user gets back his initial settings. :-)
Don't forget that the mode is only available for Android 2.2 and higher (API level 8), so you will have to use reflection if you want to target older Android versions, too. And of course you will definitely need permissions to write the system settings.
屏幕关闭由代理传感器控制,而不是光传感器。
您可以在电话应用程序中删除代理传感器的注册
screen off is controlled by Proxy Sensor, not Light Sensor.
you can remove the register of proxy sensor in Phone app
我打赌你一定会喜欢这个应用程序!!
PROXIMITY-SENSOR-OFF.apk
问候
CVS@2600赫兹
I bet you will enjoy this app then!!
PROXIMITY-SENSOR-OFF.apk
Regards
CVS@2600Hertz