How to determine the movement of the device?

I want to detect a movement like Moo Box, I cancel the phone, and when I return it, it launches the action ... For Android. What is the best way

You can configure an event listener

+3
source share
2 answers

Have you watched SensorManager ?

Here's a very good tutorial: http://www.ibm.com/developerworks/opensource/library/os-android-sensor/

Update after editing the question:

SensorEventListener is an interface, not a class, so you are forced to implement your code in two callbacks:

abstract void   onAccuracyChanged(Sensor sensor, int accuracy) // Called when the accuracy of a sensor has changed.
abstract void   onSensorChanged(SensorEvent event) // Called when sensor values have changed. 

You will be more interested in the second.

Please take a look at the tutorial that I posted above. Halfway there is an example of an accelerometer:

Sensor Example

(. Download ). , TextView. 1 .

, , , .

+6

Android. .

, .

0

All Articles