xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 505 forks source link

[Bug] missing android permission for Permissions.Sensors for StepDetector sensor #2032

Closed rgajadin closed 10 months ago

rgajadin commented 2 years ago

Description

https://developer.android.com/about/versions/10/privacy/changes#physical-activity-recognition

Permissions.Sensors requests android.permission.BODY_SENSORS but also needs android.permission.ACTIVITY_RECOGNITION for step counter and step detector sensors

Steps to Reproduce

  1. Have both <uses-permission android:name="android.permission.BODY_SENSORS"/> <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/> in your manifest
  2. Ask permission await Permissions.RequestAsync<Permissions.Sensors>()) etc..
  3. Start the StepDetector sensor var sensorManager = (SensorManager) Context.GetSystemService(Context.SensorService); var sensor = sensorManager .GetDefaultSensor(SensorType.StepDetector); sensorManager.RegisterListener(this, _sensor, SensorDelay.Normal);

Expected Behavior

I get asked to give permission to BODY_SENSORS and ACTIVITY_RECOGNITION

Actual Behavior

I only get asked to give permission for BODY_SENSORS and now the StepDetector sensor won't enable.

Basic Information

app sdk info: android:minSdkVersion="21" android:targetSdkVersion="30"

Perhaps a new permissions needs to be added?

jfversluis commented 10 months ago

Unfortunately this won't be added to Xamarin.Essentials anymore. You can extend the Permissions yourself though by following this: https://learn.microsoft.com/xamarin/essentials/permissions?tabs=android#extending-permissions

Thank you!