in Android Studio

public void SensorData() { SensorManager sensorManager= (SensorManager)currentActivity.getSystemService(Context.SENSOR_SERVICE); Sensor defaultacc = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); maxrange = defaultacc.getMaximumRange(); } 

maxrange indicates that the sensor can measure up to 39 ms ^ 2 However, the code below

 public void onSensorChanged(SensorEvent event) { if(event.sensor.getType()== Sensor.TYPE_ACCELEROMETER){ float[] values= event.values; ax= values[0]; //Вот эти значения осей не доходят даже до 20 м/c^2 ay= values[1]; az= values[2]; } 

Shows the maximum results in 2 times less - no more than 19 kopecks m / c ^ 2

What's the matter? Is it possible to raise the threshold to 39 m / s ^ 2, as it is written in the information about the sensor? Tested on multiple phones.

  • may not have shook the phone badly? - rjhdby
  • @rjhdby enough. It was the maximum value that was recorded, and if something was greater than it, it became maximum. The value has never risen above 19 with a little, although it easily reached these figures - this is only 2 free-fall accelerations. Hand can shake and 40 and 50 m \ s ^ 2. - Dmitrii
  • There are two theories: 1) Everyone lies (c). In the sense of manufacturers accelerometers. 2) 2 * 19 ... ~ 39 ... Tobish is not the maximum acceleration, but the acceleration range. From -19 to +19 - rjhdby

1 answer 1

On many phones, some sensors show incorrect maximum values.

How to solve?

1) Ask the user to shake the phone very badly and measure (that is, a kind of calibration).

2) Through the native to shoot data directly. There are many difficulties for different manufacturers of sensors.

In general, the primary task is to find out who exactly gives the wrong data. Maybe even the manufacturer himself a little cut.