AppStudio 4: Shake your booty!

One of the handy gestures you can do on a mobile device that you cannot do on the desktop is shake the entire device. It’s a handy way for the user to tell your app to clear the screen, discard the current transaction, start a new game, etc.

To do this, you need to take measurements on the accelerometer and detect a shaking motion. This is a bit complex to do: AppStudio 4 adds a library to make this easy.

Screen Shot 2014-04-03 at 6.44.24 AM

To add the library, click on “Project Properties and Global Code”. The Toolbox of libraries will display as above. Select “Shake Library”.

Now, add the following code to your app:

Sub window_onshake()
  MsgBox "Thanks for the shake!"
End Sub

That’s all there is to do. If you want to try a sample app, it is in Samples Folder 8.

(Thanks to Alex Gibson for making this library)