Activity recreation rethought
Can we really forget about handling activity recreation after locking the Android device screen orientation? I’ve been asking this question for quite some time.
And it took me a while to find the answer. Back in the days I was repeating after others, also not very smart developers, something like this: “Let’s lock the activity orientation, we’ll save a lot of time handling its recreation”.
If you start your project with such assumption, you’re going to have a hard time looking for
Most common trouble
Unfortunately the infamous
recreation has its place not only on the screen rotation. Sure, this is the most common case but there are others. I can point out two of them:
- The user has changed the system language
It’s a rare case, but still worth mentioning
- The system freed up some RAM
The user exited into the background, played some games, browsed the internet and BOOM. Sooner or later the system frees up the memory that your app keeps for itself. This will cause the
recreation when the user gets back. This obviously happens more often on less powerful devices with limited RAM. This case alone is worth handling the recreation, I assure you.
Remember, if you need to simulate the activity recreation without having rotation enabled, go into developer options on your phone and look for “Don’t keep activities” checkbox. This will cause
destruction when you enter the background or even open another