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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:06:08+00:00 2026-06-13T07:06:08+00:00

I am developing an android app that should only run in portrait mode due

  • 0

I am developing an android app that should only run in portrait mode due to the layout not fitting on a phone’s landscape screen.
On tablets and netbooks, however, I want the app to only run in landscape mode.

I’ve now tried to check if the app is running on a tablet device and setting the corresponding requested orientation via setRequestedOrientation.

The problem is that the app crashes now when the device is not already held in the orientation I’m requesting, because I display a progressDialog shortly after the call to setRequestedOrientation, which seems to leak a window then.

Logcat says:

10-18 21:15:30.698: E/WindowManager(653): Activity has leaked window  com.android.internal.policy.impl.PhoneWindow$DecorView@41991418 that was originally added here
10-18 21:15:30.698: E/WindowManager(653): android.view.WindowLeaked: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41991418 that was originally added here
10-18 21:15:30.698: E/WindowManager(653):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:279)
10-18 21:15:30.698: E/WindowManager(653):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
10-18 21:15:30.698: E/WindowManager(653):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
10-18 21:15:30.698: E/WindowManager(653):   at android.view.Window$LocalWindowManager.addView(Window.java:537)
10-18 21:15:31.888: E/WindowManager(653): Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41588040 that was originally added here
10-18 21:15:31.888: E/WindowManager(653): android.view.WindowLeaked: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41588040 that was originally added here
10-18 21:15:31.888: E/WindowManager(653):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:279)
10-18 21:15:31.888: E/WindowManager(653):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
10-18 21:15:31.888: E/WindowManager(653):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
10-18 21:15:31.888: E/WindowManager(653):   at android.view.Window$LocalWindowManager.addView(Window.java:537)
10-18 21:15:34.168: E/AndroidRuntime(653):  at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:599)
10-18 21:15:34.168: E/AndroidRuntime(653):  at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:336)
10-18 21:15:34.168: E/AndroidRuntime(653):  at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:151)

What could I do to prevent this crash?
Any help would be highly appreciated.

EDIT:
As I was not able to solve this, I finally managed to edit my Layout so that it now allows usage in portrait and landscape mode.

  • 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-13T07:06:09+00:00Added an answer on June 13, 2026 at 7:06 am

    Do you have any source code that you could show? That could help identify the problem.

    I actually had the exact same problem. But it was only happening for some of my activities.

    When the screen orientation changes, Android actually destroys and recreates the activity.

    So, I had code that looked like this.

       @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    
            setContentView(R.layout.displayscreen);
    
            bottomButton = (Button) findViewById(R.id.bottomButton);
            bottomButton.setOnClickListener(bottomButtonClick);
            bottomButton.setTypeface(font);
            bottomButton.setTextSize(16);
    }
    

    See what was happening is that the view was not attached correctly to the window manager. So I decided that the oncreate was perhaps not the best spot to be doing this.

    Instead I added it to my on Resume and it works. Like so:

       @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.displayscreen);
    
            bottomButton = (Button) findViewById(R.id.bottomButton);
            bottomButton.setOnClickListener(bottomButtonClick);
            bottomButton.setTypeface(font);
            bottomButton.setTextSize(16);
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    

    Unfortunately this also causes the the activity to still get destroyed and recreated. Calling the onCreate and onResume twice… Not good right?

    So to fix this issue. You have to add this into your android manifest for your activity.

    android:configChanges="keyboardHidden|orientation"
    

    An Example:

    <activity 
        android:name="com.Test.Info.DisplayInfo"
        android:configChanges="keyboardHidden|orientation"
        android:label="@string/info">
    </activity>
    

    This code prevents the destroy/recreate cycle.

    Hopefully this helps!

    Cheers

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

Sidebar

Related Questions

A new question about android and services. Currently I'm developing a App that should
I'm developing for Android and I have an app (called Forget-Me-Not) that uses a
I'm developing an Android App that should send an image to my ASP.NET Web
I'm developing application for android by using flex. That app should read sms from
hi guys i have been developing android app that should match most of the
I am developing an Android app that should be capable of streaming video to
I'm developing an Android app that receives the ougoing call event and extract the
I started developing an android app that have to interact with MMS attachements, in
I'm developing an Android app that uses Osmdroid to display the maps in offline
The scenario is, i'm developing an android app that uses the internet. This is

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.