Android: Handling Screen Orientation or Configuration changes

Preview version — Not completed yet, i will update this post shortly

In the pathway of developing android, you may feel like some feature/task can be accomplished in several ways. For example, Handling orientation changes.

At first it may seem a bit confusing which way you should follow or stick to?

Over the time i realized these options are available for different scenario. So, you better get to know the purpose of different techniques and how to apply them to handle screen orientation or configuration changes in android.

Why re-inventing the wheel rather not re-using it?

Before showing some code i had learned from various online/offline resources, you should look/read some guidelines

Official Android Reference
… a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(), onStop(), and onDestroy() as appropriate. …

… This is done because any application resource, including layout files, can change based on any configuration value. Thus the only safe way to handle a configuration change is to re-retrieve all resources, including layouts, drawables, and strings. …

for more information: Activity Class Ref.

Official Android Guidelines
Handling Runtime Changes

Android Developers Blog guideline
Faster screen orientation change

Fragment solution

Resource attribute configChanges

Activity attribute configChanges



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s