[Enhancement] LinearAccelerationSensor on Android
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 297
Description
## Summary
The current Xamarin.Essentials Accelerometer provides generic access to an accelerometer sensor across the platforms. It would be good to allow a way to change the requested sensor to be the LinearAccelerationSensor on Android only. The LinearAccelerationSensor excludes gravity from the readings which is very handy.
https://developer.android.com/guide/topics/sensors/sensors_motion#sensors-motion-linear
https://github.com/dotnet/maui/blob/main/src/Essentials/src/Accelerometer/Accelerometer.android.cs
## API Changes
Add an optional method parameter for the type of sensor you want to request. It falls back to Accelerometer on any platforms where other platforms are not supported.
``` charp
public static void Start(SensorSpeed sensorSpeed, AccelerometerType? accelerometerType);
```
``` csharp
public enum AccelerometerType
{
Accelerometer = 0,
AccelerometerUncalibrated = 1, // why not? :)
LinearAcceleration = 2,
Gravity = 3, // why not? :)
}
```
``` csharp
Accelerometer.Start(SensorSpeed.UI, AccelerometerType.LinearAcceleration);
```
## Intended Use Case
Linear acceleration data is very useful. There are lots of times when you want to exclude gravity from any measurements.
Contributor guide
Assessment
This issue has not been assessed yet.