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
Description
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.