Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Add SetCurrentActivityResolver + Remove dependency to Plugin.CurrentActivity #27

Copy link
Copy link
Open
@thomasgalliker

Description

@thomasgalliker
Issue body actions

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.