получить ускорение без гравитации

Я новичок в разработке Android. Я хочу получить фактическое ускорение телефона. Я нашел код для ускорения. Но он дает ускорение с силой тяжести. Пожалуйста, помогите мне найти способ получить фактическое ускорение без гравитации. Вот код, который я нашел ,, Пожалуйста, помогите мне с этим кодом. благодарю вас

    package com.SensorTest;

    import android.app.Activity;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;
    import android.os.Bundle;
    import android.widget.TextView;


    public class SensorTestActivity extends Activity implements SensorEventListener {

    SensorManager sensorManager = null;

    //for accelerometer values
    TextView outputX;
    TextView outputY;
    TextView outputZ;

    //for orientation values
    TextView outputX2;
    TextView outputY2;
    TextView outputZ2;

     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        setContentView(R.layout.main);

        //just some textviews, for data output
        outputX = (TextView) findViewById(R.id.TextView01);
        outputY = (TextView) findViewById(R.id.TextView02);
        outputZ = (TextView) findViewById(R.id.TextView03);

        outputX2 = (TextView) findViewById(R.id.TextView04);
        outputY2 = (TextView) findViewById(R.id.TextView05);
        outputZ2 = (TextView) findViewById(R.id.TextView06);


     }


    @Override
    public void onAccuracyChanged(Sensor arg0, int arg1) {
        // TODO Auto-generated method stub

    }

 @Override
 public void onSensorChanged(SensorEvent event) {
synchronized (this) {
    switch (event.sensor.getType()){
        case Sensor.TYPE_ACCELEROMETER:
            outputX.setText("acclaration x:"+Float.toString(event.values[0]));
            outputY.setText("acclaration y:"+Float.toString(event.values[1]));
            outputZ.setText("acclaration z:"+Float.toString(event.values[2]));
        break;
    case Sensor.TYPE_ORIENTATION:
            outputX2.setText("orientation x:"+Float.toString(event.values[0]));
            outputY2.setText("orientation y:"+Float.toString(event.values[1]));
            outputZ2.setText("orientation z:"+Float.toString(event.values[2]));
    break;

            }
        }
    }


    @Override
    protected void onResume() {
       super.onResume();
       sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), sensorManager.SENSOR_DELAY_GAME);
       sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), sensorManager.SENSOR_DELAY_GAME);
    }

    }

Ответы на вопрос(4)

Ваш ответ на вопрос