Thursday, 14 June 2012

Android - Accelerometer


1. File>>New>>Android Project
2. Choose Android 2.2 or later for build target
3. Click to the .java class and after the “extends Activity”, put “implements SensorEventListener”(The error will occur then point your cursor to the error and click “Add unimplemented methods”)
4. Go to layout>>main.xml, add textView’s id and modify the string
5. Declare SensorManager and TextView.
6. In onCreate method, put initial value for sensorManager  
7. Make some changes at onSensorChanged method
8. The result shows sensor value for x,y and z axis.




No comments:

Post a Comment