Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Add SetCurrentActivityResolver + Remove dependency to Plugin.CurrentActivity #27

Open
thomasgalliker opened this issue Nov 22, 2020 · 0 comments

Comments

@thomasgalliker
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant