Open jtillyt opened 4 years ago
I am also experiencing this one here is our logs
Call Stack DeviceOrientationImplementation CurrentOrientation
Exception Message System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.App.Activity'.
I think this caused when the lifecycle listener is disposed here line 24 https://github.com/jamesmontemagno/CurrentActivityPlugin/blob/f8f6e1c046087fe23117483a6f826bfe7ac627dc/src/Plugin.CurrentActivity.Android/CurrentActivity/CurrentActivityImplementation.cs. Would it be possible if the fix could have null checker here then, send the previously saved orientation back here line 55 https://github.com/wcoder/Xamarin.Plugin.DeviceOrientation/blob/12116720c8c6ee1cbf69b785a96a1253d664d0fc/src/DeviceOrientation/Plugin.DeviceOrientation.Android/DeviceOrientationImplementation.cs?
@wcoder Do you think adding the null checks in DeviceOrientationImplementation
could fix this issue?
If so: Might we introduce other side effects with this change? (e.g. broken state handling)
@wcoder @jaytilly What do you think about the null check solution?
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