0

I have been looking at other answers on here and I'm not sure any of them help me understand how to implement what I want.

I'm trying to build an app that is essentially a Magic 8 Ball. I want to know when the person starts to shake the phone and then when they stop. And when they stop, call another method that generates an answer and also disables any shaking until they press a "Ask Again" button. Any tutorials on the proper Sensors I need for this and how they work would be appreciated.

I'm pretty sure I should be implementing the SensorListener class however I'm just unsure of how it works entirely, so forwarding me to any resources would be helpful, thanks.

  • Have you not found and read: http://developer.android.com/guide/topics/sensors/sensors_overview.html as well as look at the source code for the API Demos app in the SDK? – Morrison Chang Mar 17 '14 at 20:42
  • Just use the built in accelerometer sensor to determine if the device is being shaken. Think of it from a physical sense, how would you know if you were being shaken? – zgc7009 Mar 17 '14 at 20:50

1 Answers1

0

Look at this example: http://androidexample.com/Accelerometer_Basic_Example_-_Detect_Phone_Shake_Motion/index.php?view=article_discription&aid=109&aaid=131

The article explains how to use the accelerometer with the SensorEventListener to check for shakes.

ElectronicGeek
  • 3,312
  • 2
  • 23
  • 35