简体   繁体   中英

Android Tap Device Sensor

is there a sensor in android to detect a tap on the device? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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