Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7172115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:33:04+00:00 2026-05-28T15:33:04+00:00

In Android, when the screen orientation changes (between landscape and portrait) the onCreate method

  • 0

In Android, when the screen orientation changes (between landscape and portrait) the onCreate method is called which ,if not handled properly, will recreate the entire activity when the result is too simply change the layout and retain all of the same information.

I know of a few ways to solve this, but I’m interested in the most efficient way.

1) Telling the manifest that I will handle the orientation change by overriding the onConfigurationChanged() method and leaving it empty.

2) override onSaveInstanceState() and save the data here to be repopulated in onCreate()

3) Override onPause() which will create a bundle of the data and send it to onSaveInstanceState()

Obviously, these are all options, but which one is a better practice (small, medium, large amounts of data)

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:33:04+00:00Added an answer on May 28, 2026 at 3:33 pm

    Some device configurations can change during runtime (such as screen orientation, keyboard availability, and language). When such a change occurs, Android restarts the running Activity (onDestroy() is called, followed by onCreate()).

    • To properly handle a restart, it is important that your activity
      restores its previous state through the normal Activity lifecycle, in
      which Android calls onSaveInstanceState() before it destroys your
      activity so that you can save data about the application state. You
      can then restore the state during onCreate() or
      onRestoreInstanceState().

    However, you might encounter a situation in which restarting your application and restoring significant amounts of data can be costly and create a poor user experience. In such a situation, you have two other options:

    1. Retain an object during a configuration change

      Allow your activity to restart when a configuration changes, but carry a stateful Object to the new instance of your activity.

    2. Handle the configuration change yourself

      Prevent the system from restarting your activity during certain configuration changes, but receive a callback when the configurations do change, so that you can manually update your activity as necessary.

    So, As per your data operation and coast of user experience with application you can choose what is best for you..

    EDIT: As per your need for just change the layout I think you have to use onConfigurationChanged() and do the changes in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found out that Android destroys and recreates activities during screen orientation changes. I
how can I force Android to clear it's dialog cache when screen orientation changes?
On a configuration change, such as Screen Orientation Change, Android will automatically save some
I'm creating a splash screen that will display while my Android application loads. I'd
friends, i am facing an issue related to android phone screen orientation If i
I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes
I was wondering why not use android:configChanges=keyboardHidden|orientation in every (almost every ;)) activity? Goods:
i want to know how to handle mobile screen orientation means in android mobile
I'm having a hard time with the screen orientation in Android. I have an
I have a tab-based Android app. Currently, it does not support landscape mode -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.