通话期间禁用光传感器 - Android

发布于 2024-10-03 19:32:05 字数 633 浏览 4 评论 0原文

当您在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酒废 2024-10-10 19:32:05

您需要使用的传感器是接近传感器,
试试这个,这会让您知道传感器是否隐藏(并且它在您通话时工作)

   SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
        sm.registerListener(new SensorEventListener() {

            @Override
            public void onSensorChanged(SensorEvent event) {
                Log.i(TAG,"sensor: " + event.sensor.getName() + ", values: " + Arrays.toString(event.values));

            }

            @Override
            public void onAccuracyChanged(Sensor sensor, int accuracy) {
                Log.i(TAG,"accuracy change: " + sensor + ", accuracy: " + accuracy);

            }
        }, sm.getDefaultSensor(Sensor.TYPE_PROXIMITY),SensorManager.SENSOR_DELAY_FASTEST);

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)

   SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
        sm.registerListener(new SensorEventListener() {

            @Override
            public void onSensorChanged(SensorEvent event) {
                Log.i(TAG,"sensor: " + event.sensor.getName() + ", values: " + Arrays.toString(event.values));

            }

            @Override
            public void onAccuracyChanged(Sensor sensor, int accuracy) {
                Log.i(TAG,"accuracy change: " + sensor + ", accuracy: " + accuracy);

            }
        }, sm.getDefaultSensor(Sensor.TYPE_PROXIMITY),SensorManager.SENSOR_DELAY_FASTEST);
裂开嘴轻声笑有多痛 2024-10-10 19:32:05

我会使用类 Settings.System 阅读 SCREEN_BRIGHTNESSSCREEN_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 the SCREEN_BRIGHTNESS and the SCREEN_BRIGHTNESS_MODE via getInt() before a call is made. Then I would set new values via setInt(), namely 255 for the brightness and SCREEN_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.

怪我闹别瞎闹 2024-10-10 19:32:05

屏幕关闭由代理传感器控制,而不是光传感器。
您可以在电话应用程序中删除代理传感器的注册

screen off is controlled by Proxy Sensor, not Light Sensor.
you can remove the register of proxy sensor in Phone app

巨坚强 2024-10-10 19:32:05

我打赌你一定会喜欢这个应用程序!!
PROXIMITY-SENSOR-OFF.apk

问候
CVS@2600赫兹

I bet you will enjoy this app then!!
PROXIMITY-SENSOR-OFF.apk

Regards
CVS@2600Hertz

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文