• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Detect taps on case

rhosch

Lurker
On galaxy alpha (forums still pretty empty), ATT bootloader locked so whatever I can accomplish stock for now.

I'm trying to create way to detect and count taps on the case to launch a task while the phone is asleep. For now, the goal is something like three taps on phone back while in shirt pocket to call my wife on soeakerphone (mic seems to cope well enough with the pocket).


Can't use Xperience etc without root.

Detecting a front/back shake with very short duration and moderate sensitivity seems to work OK. Plenty of false detections, but my plan was to count and require say a group of three in one second to launch the task.

So I set a variable 1 equal to time in milliseconds with a tap, variable 2 equal to time minus var 1, and var 3 equal to time minus var 2. If both var 2 and 3 are under a threshold, and/or their sum is below a threshold, launch task.

Works, except.... the sampling rate seems too slow. I can seem to detect taps closer than about one second, which makes the action both awkward and too prone to random false triggers. Looking at the monitoring settings, I don't see how to affect this.

Any ideas on how to fix what I'm doing, or suggestions on a better route entirely to take?
 
I'm trying on a Nexus 4 what you describe here (just the 1 tap for now) and the success rate is catastrophic while the phone detects the shake almost every time I put the phone down. I'm not sure how you're going to make it work.

Also, the main issue here is, I would say, that you're going to have to enable the accelerometer while the phone is asleep and that's going to drain your battery.
 
Cool, a reply... thanks!

Yeah, single tap is riddled with false detections which I expected. That's why I'm trying to count taps within a time window to significantly decrease inadvertent triggers. I'd say it works except again I can't seem to get the sampling rate or recovery rate or whatever you want to call it fast enough.

I had figured there would be a battery hit but to be honest I don't think I've left accel on long enough to see how bad because the profile hasn't worked well enough. I figured if I accomplished getting across the first bridge then I could tackle that... perhaps enabling accel under certain contexts like when BT connected in car assuming tasker would allow that.
 
Back
Top Bottom