public void onSensorChanged(SensorEvent sensorEvent){
if (sensorEvent.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
ax=sensorEvent.values[0];
sensorEvent.values[0] // for X-Axis
sensorEvent.values[1] // for Y-Axis
sensorEvent.values[2] // for Z-Axis
}
}