Does anyone know of any sample code for simple shake detector?
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.
精彩评论