CurrentActivityPlugin icon indicating copy to clipboard operation
CurrentActivityPlugin copied to clipboard

Incorrect CurrentActivity value after activities are destroyed and restored by the system

Open TimofeyBurak opened this issue 4 years ago • 2 comments

Bug Information

Version Number of Plugin: 2.1.0.4 Device Tested On: Google Pixel 4 with Android 10.0 Simulator Tested On: none Version of Rider: 2021.2 Version of Xamarin.Android: 11.3.0.4 Versions of other things you are using:

Steps to reproduce the Behavior

In our application we have two activities, DialogActivity is opened on top of MainActivity. We use Settings -> Developer Options -> Don't Keep Activities turned ON to simulate system high load. While top activity (DialogActivity) is opened - minimize the app and then open it again.

Expected Behavior

CrossCurrentActivity.Current.CurrentActivity should return instance of DialogActivity

Actual Behavior

CrossCurrentActivity.Current.CurrentActivity returns instance of MainActivity

Code snippet

Code: https://gist.github.com/TimofeyBurak/1c1924d45b5bd0a1aa82dcdf0ee908fe Logs: https://gist.github.com/TimofeyBurak/6bd989e49f421d8a84fe818e9ff9741c Looks like issue happens because paused activity also saved as current activity, which may override already resumed activity.

TimofeyBurak avatar Aug 16 '21 13:08 TimofeyBurak

Do you see this behaviour with Xamarin.Essentials? This project is no longer maintained as James moved this behaviour into Essentials, You're better off removing this package and trying with XE 😄

Axemasta avatar Sep 02 '22 14:09 Axemasta

Actually, we already did switch to XE) But it seems like XE has exactly the same implementation, at least in regards of updating current activity in OnActivityPaused(). I guess I need to double check the behaviour of XE and create an issue there, if needed.

Thank you!

TimofeyBurak avatar Sep 02 '22 15:09 TimofeyBurak