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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:10:23+00:00 2026-05-12T15:10:23+00:00

I have an application that I just would like to use in portrait mode,

  • 0

I have an application that I just would like to use in portrait mode, so I have defined
android:screenOrientation=”portrait” in the manifest XML. This works OK for the HTC Magic phone (and prevents orientation changes on other phones as well).

But I have a problem with the HTC G1 phone as I open the hardware QWERTY keyboard (not the virtual keyboard). My activity stays in portrait mode, but it seems to get restarted and loses all its states. This does not happen with the HTC Hero version.

My application is quite big, so I don’t want it to restart and lose all its states when the keyboard is opened. How can I prevent that?

  • 1 1 Answer
  • 1 View
  • 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-12T15:10:23+00:00Added an answer on May 12, 2026 at 3:10 pm

    Update April 2013: Don’t do this. It wasn’t a good idea in 2009 when I first answered the question and it really isn’t a good idea now. See this answer by hackbod for reasons:

    Avoid reloading activity with asynctask on orientation change in android

    Add android:configChanges="keyboardHidden|orientation" to your AndroidManifest.xml. This tells the system what configuration changes you are going to handle yourself – in this case by doing nothing.

    <activity android:name="MainActivity"
         android:screenOrientation="portrait"
         android:configChanges="keyboardHidden|orientation">
    

    See Developer reference configChanges for more details.

    However, your application can be interrupted at any time, e.g. by a phone call, so you really should add code to save the state of your application when it is paused.

    Update: As of Android 3.2, you also need to add “screenSize”:

    <activity
        android:name="MainActivity"
        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation|screenSize">
    

    From Developer guide Handling the Configuration Change Yourself

    Caution: Beginning with Android 3.2 (API level 13), the “screen size”
    also changes when the device switches between portrait and landscape
    orientation. Thus, if you want to prevent runtime restarts due to
    orientation change when developing for API level 13 or higher (as
    declared by the minSdkVersion and targetSdkVersion attributes), you
    must include the “screenSize” value in addition to the “orientation”
    value. That is, you must declare
    android:configChanges="orientation|screenSize". However, if your
    application targets API level 12 or lower, then your activity always
    handles this configuration change itself (this configuration change
    does not restart your activity, even when running on an Android 3.2 or
    higher device).

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

Sidebar

Related Questions

I have implemented a simple Android application that I now would like to test
I got an android application that I would like to send its use log
I currently have a UINavigationController based application that works just fine. I'd like to
I just started to use SQL Server 2008. I have a winforms application that
I have just been involved in writing an application that does not use Doctype's
I have an application that I would like to have support SQL Server Mirroring.
I have written a C++ application that uses the Qt framework. I would like
I have a MVC .NET application that I would like to expose to our
We have a utility spring-mvc application that doesn't use a database, it is just
I have a console application that i got to make and i would like

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.