Skip to content
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.

Android: Cannot access a disposed object. #23

Open
@jtillyt

Description

@jtillyt

DeviceOrientationImplementation.set_IsListenerEnabled (System.Boolean value)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Plugin.DeviceOrientation.OrientationListener'.

This is thrown when the following override in the MainActivity is called after switching away from app and then back to app:
public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
{
DeviceOrientationImplementation.NotifyOrientationChange(newConfig.Orientation);
}

Repo steps:
Tested on Android v8 and v9

  • Implement override so that NotifyOrientationChange is called in Android
  • Open app and use so the LockOrientation is called
  • Put app in background
  • Put app back in foreground
  • When changing the orientation, the app will crash because the OrientationListener is disposed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions