-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState #11259
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Hi, @jfversluis |
Here is a repro if you need it. |
Workaround: add a short delay (1ms is enough) before pushing the modal page. |
I encountered this error in my application as well. Different trigger. In my case, I have a timer thread running which periodically wakes up, checks if the user has made any recent activity. If after a certain amount of time passes and there is no activity, the thread logs the user out of their session and then replaces the MainPage with a new instance of the login screen. During this period, the device may have gone to sleep and my application is not currently displayed.
I worked around this using a combination of two people's solutions/advice. I used a TaskCompletionSource to gate the logout function until the app resumed, if the app wasnt already running, and also added an await Task.Delay(100), which was also necessary. |
I think what also might work for you here is to check You can add an event to window.resumed/window.activated once that fires you can then swap out the main page or do whatever it is you need to do |
Nice, thanks! That might be simpler than what I ended up implementing. I used App.xaml.cs's OnResume and OnSleep methods, and just wrote a bool flag into my session manager object which I used to determine app state. |
@PureWeen |
Description
Exception on app resume on android, when pushing a modal page.
No exception on a similar scenario with xamarin forms.
This looks similar to xamarin/Xamarin.Forms#1378.
Maybe you should simply change from
Commit()
toCommitAllowingStateLoss()
, as done here: xamarin/Xamarin.Forms#527.Steps to Reproduce
Link to public reproduction project repository
...
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: