Android Lock Orientation And Double Create
Solution 1:
I believe that using the Activity's configChanges
attribute (in the manifest) should solve your problem. ConfigChanges attribute documentation
However, you are just going around another problem. What you really should address is why is that provoking FC? There is absolutely no reason for that to happen so you also should solve that problem. More info in handling runtime changes.
Please note: using the first approach is acceptable to address the performance/UX issues though.
Just in case you wonder why onCreate
is called twice, once I got into this problem and I think that it was related to having the orientation fixed and then having another activity being created but in a different orientation. Before the second activity was started, the former activity changed into the orientation of the latter. And remember that keyguard is also an Activity! I'm not sure if this happens for this reason though.
Solution 2:
don't put : "setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);". Just let the AndroidManifest do his job. I thing what you did is :
- Tell your App to go only in Portrait mode
- Tell your Activity to be in Portrait mode, wherever it was already like this or not (The flash have to come from this).
- I could be wrong.
Post a Comment for "Android Lock Orientation And Double Create"