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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:26:13+00:00 2026-05-30T19:26:13+00:00

Here’s my MAIN ACTIVITY public static boolean popupStatus=false; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

  • 0

Here’s my MAIN ACTIVITY

    public static boolean popupStatus=false;
    public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null){
    popupStatus = savedInstanceState.getBoolean("Open");
    } 
    setContentView(R.layout.main);

    public void onSaveInstanceState(Bundle savedInstanceState) {    

    savedInstanceState.putBoolean("Open", DateTimePicker.openPopup);
    super.onSaveInstanceState(savedInstanceState);
}

I have DateTimePicker.java class which has 1 button and 1 Textview. Clicking on button, my another class Calendar.java get populated in PopupWindow and this Popup window displays my class Calendar.java . I have created different layouts of my Calendar.java class for portrait and landscape mode. Here’s DateTimePicker.java some snippet of code,

    public static boolean openPopup = false;

    textView = new TextView(this.getContext());
    this.addView(textView, layoutParams);
    button = new Button(this.getContext());
    button.setText("C");
    this.addView(button, layoutParams1);
    button.setOnClickListener(this);
    if(Main.popupStatus){
            button.performClick();
        }

    public void onClick(View v) {
    if(Main.popupStatus){
              new Handler().postDelayed(new Runnable() {
                    public void run() {
                        openCalendar();
                    }
                }, 100);
        }
        else{
            openCalendar();
        }

    private void openCalendar() {
    Calendar calendar = new Calendar(this.getContext());
    if(portrait.equals(orientation)){
        pw = new PopupWindow(calendarLayout, 245, 284, true);
    }
    else{
        pw = new PopupWindow(calendarLayout, 295, 240, true);
    }
    pw.setOutsideTouchable(false);
    pw.showAtLocation(this, Gravity.NO_GRAVITY, 10, 80);
    openPopup = true;
}

    public void closeCalendar(){
    pw.dismiss();
    openPopup = false;
        }

Main.XML contain DateTimePicker .
Actually I wanted my Popup window to be opened up even when orientation gets changed at run time, so I have done it through setting flag openPopup = true; in openCalendar() method and if it is opened and orientation gets changed at run time, this flag will be saved in onSaveInstanceState() method. After orientation will change, it will be checked in onCreate() and popup will be opened up for respective orientation mode. I hope you got my point.

PROBLEM: Initially When I click on button in Portrait mode, popup window pops up for portrait layout. then without dismissing popup window, I change the orientation to landscape. And after changing, I can see my popup window as intact and appears on screen of landscape layout. Till now it works fine. But IF popup window is opened up in landscape mode and then I change the orientation to portrait, popup window of portrait layout didn’t come up and I see FORCE CLOSE message:/ Please help since I am working behind it so long and getting no clue. I would be very grateful to you all. Thanks!

P.S.: Changing orientation means I am pressing ctrl+F11 and changing orientation of Emulator

  • 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-30T19:26:14+00:00Added an answer on May 30, 2026 at 7:26 pm

    The emulator has an odd feature (some consider it a bug) in which changing from landscape to portrait in the emulator causes two configuration changes and two restarts of your activity. (One configuration change is the orientation and the other is an emulated change in the keyboard state.) The timing of the configuration changes frequently causes crashes like this. Try adding this attribute:

    android:configChanges="keyboard|keyboardHidden"
    

    to your <activity> tag in the manifest. See if that improves the situation.

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

Sidebar

Related Questions

Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is some code on the javascript side for form-based uploads: iframe.setAttribute('src', 'javascript:false;'); I'm
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes

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.