在我的应用程序中,我需要检测用户何时倾斜他的设备(左或右)。
在Android源代码中,有一个倾斜检测器。
/**
* A sensor of this type generates an event each time a tilt event is detected. A tilt event
* is generated if the direction of the 2-seconds window average gravity changed by at
* least 35 degrees since the activation of the sensor. It is a wake up sensor.
*
* @hide
* @see #isWakeUpSensor()
*/
public static final int TYPE_TILT_DETECTOR = 22;但是它有一个@hide注释,所以我不能使用它。来自SO的这个回答说:
顺便说一下,Sensor.TYPE_TILT_DETECTOR .隐藏在SDK中,因为它们只用于系统UI。
这真的很烦人,因为它似乎正是我需要的功能。我们有什么理由不能用它吗?我真的需要改造方向盘吗?
发布于 2022-02-20 19:30:14
不幸的是用22号就行了。我也有同样的问题,但22号适合我。
https://stackoverflow.com/questions/41169053
复制相似问题