Tag Archives: event.values[0]

How to use Accelerometer in Android?

By | May 30, 2012

This is a simple post showing how to use accelerometer in android. This java code prints the values of x,y and z axis in the console. [java] package com.coderzheaven.pack; import android.app.Activity; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; public class AccelerometerTest extends Activity implements SensorEventListener{ private SensorManager sensorManager; double ax,ay,az; // these are the acceleration… Read More »