Issue
I have gone through different posts and questions for handling rotation and AsyncTask
. In each post it is mentioned that using android:configChanges
is a bad practice. But i didn't find the actual reason why it is discouraged and why it is a bad practice. What are the disadvantage if we use android:configChanges
to handle orientation.
Note:
I know it is already answered how to handle orientation and AsyncTask
. but I want to know reason behind not using android:configChanges
.
Solution
Well, you need to remember that an Activity
can be restarted for multiple reasons.
For example, one of these reasons is when your app is in the background and the OS decides to kill it (with your Activity
, of course) to reclaim memory.
When you return to your app, the OS will try to recreate your Activity
as you left it, but will fail to do so, because you decided not to bother with it, just used android:configChanges
in your Manifest.
If you make sure your app can recover properly from a restart, android:configChanges
might not be necessary at all. Because of this, the need to use android:configChanges
might indicate some flaw in your app, that may worth to take a look at.
It's not bad practice to use android:configChanges
, but it pretty easily can be, if you don't understand exactly what you're doing.
Answered By - earthw0rmjim
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.