de.palmmedia.android
Class ShakeDetector

java.lang.Object
  extended by de.palmmedia.android.ShakeDetector

public class ShakeDetector
extends Object

Detects when the device is shook. Only one SensorEventListener can be notified in the current implementation.

Author:
Daniel Palme

Field Summary
private  float last_x
          The last position.
private  float last_y
          The last position.
private  float last_z
          The last position.
private  long lastEvent
          The time of the last published event.
private  long lastUpdate
          The time of the last received sensor event.
private  SensorManager sensorMgr
          The SensorManager.
private static int SHAKE_THRESHOLD
          The minimum speed.
private  ShakeEventListener shakeEventListener
          The ShakeEventListener which is notified when a shake is detected.
private  float x
          The current position.
private  float y
          The current position.
private  float z
          The current position.
 
Constructor Summary
ShakeDetector()
           
 
Method Summary
 void onAccuracyChanged(Sensor arg0, int arg1)
          
 void onSensorChanged(SensorEvent sensorEvent)
          
 void start(Activity activity, ShakeEventListener shakeEventListener)
          Starts the shake detection.
 void stop()
          Stops the shake detection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shakeEventListener

private ShakeEventListener shakeEventListener
The ShakeEventListener which is notified when a shake is detected.


sensorMgr

private SensorManager sensorMgr
The SensorManager.


lastUpdate

private long lastUpdate
The time of the last received sensor event.


lastEvent

private long lastEvent
The time of the last published event.


x

private float x
The current position.


y

private float y
The current position.


z

private float z
The current position.


last_x

private float last_x
The last position.


last_y

private float last_y
The last position.


last_z

private float last_z
The last position.


SHAKE_THRESHOLD

private static final int SHAKE_THRESHOLD
The minimum speed.

See Also:
Constant Field Values
Constructor Detail

ShakeDetector

public ShakeDetector()
Method Detail

start

public void start(Activity activity,
                  ShakeEventListener shakeEventListener)
Starts the shake detection.

Parameters:
activity - The activity.
shakeEventListener - The ShakeEventListener.

stop

public void stop()
Stops the shake detection.


onSensorChanged

public void onSensorChanged(SensorEvent sensorEvent)


onAccuracyChanged

public void onAccuracyChanged(Sensor arg0,
                              int arg1)