Skip to content

Conversation

@tenJirka
Copy link

For some reason, I wasn´t able to find out why, on my phone (Pixel 7, android 14) is main activity always recreated when screen is rotated, and app always forget in which state it was. I was not able to replicate this behavior in android studio emulator, which is weird. It is really annoying so I decided to add feature to restore MainActivity from previous state.

For the same reason no full screen setting (hide status bar) was called so I added it to onCreate function. All edits would be called once on devices without this problem, which should be fine, and this will work as back up for devices which do have same problem.

Bonus is, that this will work every time, that for example split screen should now work better (App will not "restart").

@tenJirka tenJirka changed the title Added onSaveInstanceState Android: Added onSaveInstanceState May 10, 2024
@tenJirka
Copy link
Author

tenJirka commented May 10, 2024

After adding screenLayout into manifest, app works properly even on my phone + it handles better split screen transformations.
Not sure why it was needed on my phone and not in the emulator.

Previous changes is not so much needed now, but in my opinion it is probably better to have them in the app as backup, if anything other will appear.

@pulsejet
Copy link
Owner

Good catch. I'd remove the state saving if it's not required. Just saving the url is not sufficient state (that would require perfect deep linking, and there's other things that we rely on like browser history state). If it gets triggered it might give rise to more subtle bugs (having a more "noisy" issue is always better)

@pulsejet
Copy link
Owner

Probably worth adding more props from here
https://developer.android.com/guide/topics/manifest/activity-element

We should be able to handle basically any change.

Jiří Stehlík added 2 commits May 12, 2024 09:35
Changes done in this file is not need and was more like a hack
@tenJirka
Copy link
Author

I understand. I removed the state saving and added all the props from the link you suggested (hope I understood you correctly). I left the fullscreen setting in onCreate() to compensate for opening from landscape.

@pulsejet pulsejet merged commit c107a52 into pulsejet:master May 17, 2024
@pulsejet
Copy link
Owner

Thanks @tenJirka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants