Display android accelerometer values in degrees

0

I'm developing an android app that uses the ACCELEROMETER sensor. I need to measure the slope in degrees. I was able to instantiate the sensor to get measurements of it, display the X, Y and Z axes in TextViews. However, the values that the sensor returns to me are not in degrees. I searched to see if it was in which unit these data are displayed / measured by the ACCELEROMETER, but without success. Thanks in advance to anyone who can help me.

//Atributos para trabalhar com a camera
private Camera camera;
private FrameLayout frameLayout;
private ShowCamera showCamera;

//Atributos para trabalhar com os eixos
private TextView textViewX;
private TextView textViewY;
private TextView textViewZ;

//Atributos para trabalhar com o Acelerometro
private Sensor sensor;
private SensorManager sensorManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.frameLayout = (FrameLayout) findViewById(R.id.frameLayoutCamera);

    this.camera = Camera.open();
    this.showCamera = new ShowCamera(this, camera);
    this.frameLayout.addView(showCamera);

    textViewX = (TextView) findViewById(R.id.textViewX);
    textViewY = (TextView) findViewById(R.id.textViewY);
    textViewZ = (TextView) findViewById(R.id.textViewZ);

    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    sensorManager.registerListener(MainActivity.this, sensor, SensorManager.SENSOR_DELAY_NORMAL);

}

@Override
public void onSensorChanged(SensorEvent event) {
    textViewX.setText("" + event.values[0]);
    textViewY.setText("" + event.values[1]);
    textViewZ.setText("" + event.values[2]);

}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {

}
    
asked by anonymous 21.04.2018 / 21:22

0 answers