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

  • Home
  • SEARCH
  • 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 7815163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:25:56+00:00 2026-06-02T05:25:56+00:00

I am a beginner in android programming, now i am working on an android

  • 0

I am a beginner in android programming, now i am working on an android application which displays the data in a sort order by default and also provides a search facility. For this i have written an activity called search that will search the contents and displays in a listview. My problem is when i rotate the device the onCreate method of the Activity class is called even after overridding the onConfigurationChanged method. I had also done the following changes in the manifest file to invoke the onConfigurationChanged method.

<activity
    android:name=".Search"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="sensor" >
</activity>

My Search Activity is as follows :

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  System.out.println("HERE AT ONCREATE");
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    System.out.println("HERE AT ON CONFIGURATION CHANGED");
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.search_port);
    } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setContentView(R.layout.search_land);
    }
}

So the output while rotating the device will be :

  1. HERE AT ON CONFIGURATION CHANGED

  2. HERE AT ONCREATE

I dont want to get the onCreate() method called while rotating the device. Please help me to solve this issue. I am using Android 2.2 SDK with Samsung Galaxy Tab (7 inch display).

  • 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-02T05:25:57+00:00Added an answer on June 2, 2026 at 5:25 am

    What you’re trying to accomplish with the above code can be done much more simply.

    If you change your layout files name to be both the same: search_layout.xml and place them in your project this way :

    <project>/res/layout/search_layout.xml       // Portrait Layout
    <project>/res/layout-land/search_layout.xml  // Landscape Layout
    

    And then modify your Activity this way :

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("Search Activity", "onCreate() was called.");
    }
    
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.i("Search Activity", "onConfigurationChanged was called.");
    }
    

    That’s how I have it setup in my Activity and the onCreate() method is only called once.

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

Sidebar

Related Questions

I am a beginner in Android programming. I want to build a simple application
I am a beginner of Android programming and working my way through the Notepad
I am a beginner programming android. I am searching for info how to create
I am a beginner when it comes to programming with Android/Java, and I am
I am beginner to programming for android. First of all i need that my
I am a beginner in android programming. My Graduate project is about tracking a
I am a beginner in Android programming. I was going through the official tutorial
I am a beginner to android programming. So I am sorry if some of
I started learning android programming a couple of weeks ago. I am a beginner
I'm a beginner in Android development but not in programming itself. Anyway, this question

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.