如何读取压力传感器?

问题描述 投票:0回答:1

在大多数设备上可以轻松检测到按下物理主页按钮:

...

public class ExampleAccessibilityService extends AccessibilityService {

    ...

    @Override
    protected boolean onKeyEvent(KeyEvent event) {    
        if (event.getKeyCode() == KEYCODE_HOME && event.getAction() == ACTION_DOWN)
            Log.d("Example", "The home key is pressed.");
        return super.onKeyEvent(event);
    }
}

但是上面的代码在某些带有压力感应虚拟主页按钮的设备上不起作用。我想这些三星Galaxy设备会受到影响:S8S8+,S9,S9 +,Note10, Note10+ and Fold。正式地,它被认为是压力传感器,而不是按钮。

Screenshot of Samsung Galaxy S9 and S9+ specs on https://www.samsung.com/global/galaxy/galaxy-s9/specs/. Sensors: Iris, Fingerprint, HR, Pressure (!), Gyro, Proximity, Accelerometer, Geomagnetic, RGB Light, Barometer, Hall sensor. Buttons: On/Off, Volume, Bixby. (Home key is not on the list.)

如何读取此传感器?

TYPE_PRESSURE sensor event与气压计TYPE_PRESSURE相关。

it shows the ambient air pressure in hPa or mbar返回getPressure() method

我不需要有关压力水平的信息,我只想知道是否按下了压力感应虚拟主页按钮。

android android-sensors android-homebutton samsung-galaxy
1个回答
0
投票

据我所知,从技术上讲,它不被认为是传感器,所以不能使用。>

getPressure()

我已经记录了具有压敏虚拟主页按钮的设备的所有可用传感器,但是该按钮不在列表中。我想知道,"the size of the capacitive object rather than literal pressure"

© www.soinside.com 2019 - 2024. All rights reserved.