Android: how to handle screen orientation change

User Interfaces need to be updated when configuration of device is changed. Configuration changes are such as a change in screen orientation, language, input devices, etc. If you do not specify how configuration will be handled then this change will cause destroy the current activity and create the activity instance that goes through its life cycle.

Here Screen Orientation change is considered. If you don’t set how activity will interact when the screen orientation changes then it may happen that application will face freeze or any other errors.

It can be bypass the restarting activity by setting attribute in AndroidManifest.xml with the android:configChanges=”orientation” for  Screen Orientation configuration change so that activity itself manage the config changes.

In AndroidManifest.xml file:

 


<activity android:name=".BaseActivity"  android:configChanges="orientation"/>

 

That’s all. Have a nice Android coding.

References:

Advertisements

About M Moniruzzaman
A passionate software engineer, have been developing applications on various platforms such as Android, iPhone, .Net (C#) technologies and web based ASP.NET, PHP, JavaScript, jQuery technologies for more than 10 years. Especially I have expertise on developing applications for Android and iPhone, as well as service oriented, client-server based applications where clients will be reside on Android/iPhone that communicate with WCF(.NET) service hosted on server. I have completed certification in Microsoft Certified Professional Developer (MCPD) on .Net 4 . I have completed my graduation in -- B.Sc. (Engineering) in Computer Science and Engineering, ShahJalal University of Science and Technology, Bangladesh. Thanks, M. Moniruzzaman (Zaman)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: