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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:16:28+00:00 2026-06-15T05:16:28+00:00

I have a hello world-ish sample app that uses the android-support-v4 fragments API. The

  • 0

I have a “hello world”-ish sample app that uses the android-support-v4 fragments API.
The activity consists of a button, clicking it will show a DialogFragment.
However, configuration changes like rotation cause the dialog to vanish, even if setRetainInstance(true) is used.

Any idea how to fix this?

RetFragment.java

package me.local.HelloFroyo;

import android.os.Bundle;
import android.support.v4.app.*;
import android.util.Log;
import android.view.*;

public class RetFragment extends DialogFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.hello_dialog_fragment, container);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e("RET", "onDestroy");
    }
}

MainActivity.java

package me.local.HelloFroyo;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;

public class MainActivity extends FragmentActivity {

    private static final String TAG_DLG = "myFragDlg";

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_main);
    }

    public void onShowClick(View v) {
        RetFragment ret = new RetFragment();
        ret.show(getSupportFragmentManager(), TAG_DLG);
    }
}
  • 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-15T05:16:29+00:00Added an answer on June 15, 2026 at 5:16 am

    Just to comment on this:

    “even if setRetainInstance(true) is used.”

    It’s not “even if”, it’s “because of it.” If setRetainInstance is false, the dialog is rotated just fine.

    This is the work around I found here, which works fine for me: http://code.google.com/p/android/issues/detail?id=17423

    @Override
    public void onDestroyView()
    {
        Dialog dialog = getDialog();
    
        // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
        if ((dialog != null) && getRetainInstance())
            dialog.setDismissMessage(null);
    
        super.onDestroyView();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple PHP app that prints 'hello world'. When I run it
I have Hello World code that uses function fhi from another hi.cpp file that
Does anyone have a hello world sample or tutorial for creating an Eclipse plugin
I have developed the Hello World Android application using Eclipse. I can run the
I am new to phonegap and android, I have create a hello world application
In my hello world application, i have a button and a text field set
I have this simple hello world version of a google map api javascript v3
I have a trivial Hello world C++ program that is compiled to 500kB executable
I have a simple Hello World application public class TestLeaksOnFinish extends Activity { static
I have a simple Hello World application in Python that i'm using with AppEngine,

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.