EDITING BOARD
RO
EN
×
▼ BROWSE ISSUES ▼
Issue 65

When do screen orientation changes matter?

Adina Verzes
Android Developer @ The Arktech



PROGRAMMING

There are 4.77 billion mobile phone users spread all over the world. They can choose between 2.8 million apps on the Android platform and over 2.2 million on Apple's App Store. Mobile phones are used in schools, on the streets, in the buses, inside personal cars, everywhere. The statistics confirm that it's a real challenge to deal with the mobile device diversity. The app should work and look good on all devices, regardless of their size, orientation or capabilities. Currently, the most popular screen size is 5.4 inches (i.e. iPhone 6) because it was rated as the best size that fits the human hand. Recent studies show that most users hold their phones with one hand and that they prefer portrait mode. However, they often rotate their devices from ergonomic reasons.

Have you wondered how you prefer to hold your phone?

There are many factors which influence the way users hold their devices. These factors can be classified into two main categories - internal and external.

Internal factors are related to the content of the app. In some cases, giving support for both orientation modes is an improvement for an app, but in others it is not. The app's category and its main features influence the user's needs and expectations. The external factors imply a lot of variables, making the analysis of the user behavior very difficult and volatile. It refers to the user profile, device, mood, activity or place. Why does the user prefer one orientation despite the other? A mix of those factors is the answer.

The scheme below illustrates an example of how external factors influence the user in choosing a screen orientation.

How does this impact my app?

Facebook, YouTube and Gmail, which are the most used apps in the world, provide support for both orientations. In some cases users prefer one orientation more than the other. By giving users the option to switch between these two, they may increase their satisfaction. On the other hand, if this feature is not really useful, a lot of time and money will be wasted with its implementation.

In Android, the orientation changes are a little tricky to manage. An event is triggered by the system whenever you turn the device from one orientation to another, causing a configuration change. The default behavior of an activity is to restart when (onDestroy() is called, followed by onCreate()). In general, it's recommended to let the system handle these events. However, if you want to avoid restarting your activity you can declare this event in the manifest file, in the android:configChanges attribute.

<activity android name=".MainActivity"
            android:configChanges="orientation|keyboardHidden
               android:label="@string/app_name">

In order to decide to support screen orientation changes, think about the following questions:

Still confusing? Let's find out more about the two orientations.

The landscape mode is frequently used in media apps where the content can be viewed in a better perspective. Especially on devices with a small screen, users prefer to use the keyboard in this mode. When your fingers are bigger than the keys, you are prone to make a lot of writing mistakes, like tapping the wrong key. Besides this, some people may feel more comfortable to write with both hands and this is more easily done by using this mode. The apps usually used in landscape mode are the ones used for navigation, games, or the ones which involve a good view and control.

The portrait mode is preferred in performing quick commands, like initializing a call, scanning a QR code, setting an alarm, etc. Moreover, texts are often preferred to be read in this mode because more text can be displayed at once and the scrolling is smoother. It's easier to hold devices with one hand only when using this mode.

How to handle the switch orientation event?

Let's think about a real situation:

You've invited 3 guests at dinner. The tablecloth, the plates and the glasses have been placed carefully on table. It seems a very pleasant dinner until 2 more friends come unexpectedly.

What do you do?

You should rearrange the table, but without disturbing the other guests which are already eating and enjoying the dinner. The people who are already sitting at the table expect to find everything in a similar position after the new arrangement. Therefore, it's not a good idea to add or take off other things from the table. A good fix is to minimize the changes and integrate two more plates and glasses for your latest guests.

"A user interface is like a joke. if you have to explain it it's not that good."

Things look similar in the world of mobile phones: the users frequently rotate the phone by mistake, without any intent to do it. Even by mistake, the users expect to see the same content after a rotation. Their eyes will be focused in the same direction as before the change in orientation. Therefore, the design for both orientations should be similar in order for users to maintain their focus. Consistency is one of the major keys of successfully handling the orientation changes.

In Android, before restarting the activity, onSaveInstanceState() is called to save the current application state. You can override this method to save your own data and to restore it use onCreate() or onRestoreInstanceState(). You can define an alternative layout for the landscape orientation like this:

Project/
      res/
          layout/
            activity_login.xml
         layout-land/
            Activity_login.xml

Conclusion

For me, giving the users support for both orientations means more freedom for them. Before deciding whether I would support orientation changes, or not, I would try to understand my users' needs very well. If I realize that it's an improvement for my app, I would invest in giving support for both orientations. Building an app is easy, but building a successful app isn't. Providing support for both orientations can contribute towards building a successful app!

Conference TSM

VIDEO: ISSUE 109 LAUNCH EVENT

Sponsors

  • Accenture
  • BT Code Crafters
  • Accesa
  • Bosch
  • Betfair
  • MHP
  • BoatyardX
  • .msg systems
  • P3 group
  • Ing Hubs
  • Cognizant Softvision
  • Colors in projects

VIDEO: ISSUE 109 LAUNCH EVENT