简体   繁体   English

Android Tap设备传感器

[英]Android Tap Device Sensor

is there a sensor in android to detect a tap on the device? android中是否有传感器来检测设备上的点击? I have a service and I want to detect when the user touches the phone. 我有一项服务,我想检测用户何时触摸电话。 He can touch(tap) the screen, back or any other part of the device and it will trigger a function within my service. 他可以触摸(点击)屏幕,设备的背面或其他任何部分,这将触发我服务中的功能。 Is that possible? 那可能吗? For example, if I have the device in my pocket, and I want my service to call a certain function when the user tap the phone from outside his pocket. 例如,如果我将设备放在口袋里,并且当用户从口袋里轻按电话时,我希望我的服务调用某个功能。 Thanks. 谢谢。

You can use the accelerometer. 您可以使用加速度计。 The accelerometer detects a force on the device, and a tap would cause a force. 加速度计检测到设备上的作用力,轻击会引起作用力。 The trick would be filtering out other forces, such as bouncing when walking. 诀窍是过滤掉其他力量,例如走路时弹跳。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM