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 8251327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:12:00+00:00 2026-06-08T00:12:00+00:00

I know this question was already asked, but mine is a little different: I

  • 0

I know this question was already asked, but mine is a little different:

I have 2 different layout files for my game; one for portrait mode and one for landscape. When I rotate the screen, the onCreate method restarts my game (creates all the elements again). I don´t want this to happen, so I wrote this line in the manifest:

android:configChanges="orientation"

It works, onCreate is not called, but the new layout is not being showed properly!

I tried to put the following code in my Activity, but it just keeps doing weird things:

@Override
public void onConfigurationChanged(Configuration newConfig) {
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.gameview);
}

how can I fix this?
thanx guys

  • 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-06-08T00:12:01+00:00Added an answer on June 8, 2026 at 12:12 am

    First of all understand how orientation changing in android works:

    1. By default activity restarts on orientation changed event (and goes throw onCreate).

    2. If you write android:configChanges="orientation" in manifest – it means it will not be recreated, but just remeasure and redraw view tree.

    Comments about your code:

    • If you have different layout for different orientations – you have to recreate activity on orientation changed.
    • Method setContentView should called just once per activity lifecycle.

    General way to handle this situation is:

    1. Save game state in method onSaveInstanceState
    2. In onCreate method restore game state if it is supplied (savedInstanceState param is not null).
    3. Remove listening of configuration changing from manifest.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I know this question have been asked plenty of times already, but I
I know this question already have been asked. But I could not find any
I know this question might have been asked a few times already, but I
I know this is a similar question to one already asked, but I was
I have asked this question today already but this time I want to know
I know this question have been already asked ( here ), but all the
I know this question might have already been discussed a thousands of times but
sorry I know this question was asked already but the solution doesn't work for
I know this question was already asked in the past, but i am really
This question may have been asked already - but unfortunately, I could not find

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.