You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
Currently, Xamarin.Plugin.DeviceOrientation uses the Plugin.CurrentActivity nuget package in the Android implementation to access the current activity. This is the same behavior as many plugins use. However, since the rise of Xamarin.Essentials (which also offers access to Android's current activity), I would propose to eliminate the direct dependency to Plugin.CurrentActivity. Instead, I'd add a new static method to CrossDeviceOrientation: SetCurrentActivityResolver(Func activityResolver) which dynamically resolves the current activity from either Plugin.CurrentActivity or Xamarin.Essentials (or another plugin).
Currently, Xamarin.Plugin.DeviceOrientation uses the Plugin.CurrentActivity nuget package in the Android implementation to access the current activity. This is the same behavior as many plugins use. However, since the rise of Xamarin.Essentials (which also offers access to Android's current activity), I would propose to eliminate the direct dependency to Plugin.CurrentActivity. Instead, I'd add a new static method to CrossDeviceOrientation: SetCurrentActivityResolver(Func activityResolver) which dynamically resolves the current activity from either Plugin.CurrentActivity or Xamarin.Essentials (or another plugin).
A similar solution is successfully used in the Fingerprint plugin (https://github.com/smstuebe/xamarin-fingerprint). Check the following CrossFingerprint.Android.cs file:
https://github.com/smstuebe/xamarin-fingerprint/blob/9fb42c4a8b620260c0c03eb2714e2e03a92d472b/src/Plugin.Fingerprint/Platforms/Android/CrossFingerprint.Android.cs
What do you think of this proposal for extension?
The text was updated successfully, but these errors were encountered: