开发者

Does anyone know of any sample code for simple shake detector?

开发者 https://www.devze.com 2023-01-07 04:25 出处:网络
I\'m looking for an android code example on how I would be able to make my phone listen for a \"shake\" and then have it trigger webview.reload(); to simply reload the webview on th开发者_JAVA百科e ac

I'm looking for an android code example on how I would be able to make my phone listen for a "shake" and then have it trigger webview.reload(); to simply reload the webview on th开发者_JAVA百科e activity. Anyone have any insight on this topic?


You can try the Shaker class from this project.


I think its just as simple as read the accel, watch the x accel, look for a pos peak about 1G, (this sample is the first that is less than the previous couple of samples), increment a counter. After three 'shakes', you're golden. You have 2 params to adjust... threshold and reps.

0

精彩评论

暂无评论...
验证码 换一张
取 消