Dialog Survival Over Configuration Change

by Marco Nelissen » Thu, 05 Mar 2009 01:22:00 GMT


Sponsored Links
 


Why do you say that? Opening or closing the keyboard counts as a
configuration change, so it's something that can happen at any time.


Unless you take measures to avoid it, a configuration change will
cause your activity to be destroyed and recreated with the new
configuration. It goes through the normal activity lifecycle when
doing this, so to the current activity is paused, stopped and
destroyed, and the new activity is created, started and resumed.

--~--~---------~--~----~------------~-------~--~----~



Dialog Survival Over Configuration Change

by Romain Guy » Thu, 05 Mar 2009 02:57:05 GMT


 orry I got confused, you want removeDialog(), not dismissDialog().
The latter only closes the dialog but it is still known as a managed
dialog. removeDialog() on the other hand tells the Activity to forget
about the dialog *and* to dismiss it.

On Wed, Mar 4, 2009 at 10:53 AM, Nmix <nepean...@gmail.com> wrote:



--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support. All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Dialog Survival Over Configuration Change

by Dianne Hackborn » Thu, 05 Mar 2009 10:23:58 GMT


  think you are getting yourself into a more and more tangled mess.  As a
fairly broad rule, you shouldn't be doing any state-changing behavior in
onSaveInstanceState() -- this is not for the system to tell you about
something interesting happening, but for it to get your current state at
whatever point it thinks it might need it.

Could we back up and look at exactly what you are trying to do? In which
situations do you want the dialog to stay, and in which do you want it to
disappear? This shouldn't be in terms of "when state is saved" or "when it
is destroyed", but "when the user flips the lid / changes the
configuration," "when the user presses home," "when the user switches to
another activity," etc.

On Wed, Mar 4, 2009 at 5:28 PM, Nmix <nepean...@gmail.com> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support. All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



Dialog Survival Over Configuration Change

by Romain Guy » Fri, 06 Mar 2009 13:14:13 GMT


 gt;> It is a problem. In my, and others', opinion it is a *bug* that the

It is a bug indeed.




--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support. All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Resetting a HTTP InputStream...is this possible?

It would seem to me that a more logical approach would be to save the
stream when reading it then parse the data rather than re-read the
stream a second time. What if the second time there was an error? I'm
not positive how this works, it may be that the stream is cached so
you're not actually making a second http request by resetting it, but
then again, you may in which case it would be very wasteful to reset.

-John Coryat

"Radar Now!"

"What Zip Code?"

2. EditText.getText() not working

I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as
shown below.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/activity_background">
        <EditText
                android:id="@+id/text1"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:layout_marginLeft="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text2"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text1"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text3"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="4dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text2"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text4"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text3"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text5"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text4"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text6"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="4dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text5"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text7"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text6"
                android:layout_alignTop="@id/text1"
                android:selectAllOnFocus="true" />

....
....
....
....
....


        <EditText
                android:id="@+id/text80"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:layout_marginRight="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text79"
                android:layout_alignTop="@id/text73"
                android:selectAllOnFocus="true" />
        <EditText
                android:id="@+id/text81"
                android:layout_width="33dip"
                android:layout_height="33dip"
                android:background="@color/textBox_background"
                android:layout_marginBottom="2dip"
                android:maxLength="1"
                android:textColor="@color/textBox_color"
                android:numeric="integer"
                android:paddingLeft="11dip"
                android:layout_toRightOf="@id/text80"
                android:layout_alignTop="@id/text73"
                android:selectAllOnFocus="true" />
        <Button
                android:id="@+id/solveButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/text73"
                android:layout_alignParentRight="true"
                android:layout_marginTop="10dip"
                android:text="Solve" />
        <Button
                android:id="@+id/resetButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@id/solveButton"
                android:layout_alignTop="@id/solveButton"
                android:text="Reset" />
</RelativeLayout>

In my activity class, I have grouped all these 81 EditTexts into one 2-
dimensional array as shown below.

EditText[][] textArray = new EditText[9][9];

textArray[0][0] = (EditText)findViewById(R.id.text1);
textArray[0][1] = (EditText)findViewById(R.id.text2);
textArray[0][2] = (EditText)findViewById(R.id.text3);
textArray[0][3] = (EditText)findViewById(R.id.text4);
textArray[0][4] = (EditText)findViewById(R.id.text5);
textArray[0][5] = (EditText)findViewById(R.id.text6);
textArray[0][6] = (EditText)findViewById(R.id.text7);
textArray[0][7] = (EditText)findViewById(R.id.text8);
textArray[0][8] = (EditText)findViewById(R.id.text9);
textArray[1][0] = (EditText)findViewById(R.id.text10);
textArray[1][1] = (EditText)findViewById(R.id.text11);
textArray[1][2] = (EditText)findViewById(R.id.text12);
textArray[1][3] = (EditText)findViewById(R.id.text13);

...
...
...

textArray[8][8] = (EditText)findViewById(R.id.text81);


Now when I try to do a simple getText() method on textArray[][], it
gives me a runtime error but setText() method works fine on textArray[]
[]

textArray[i][j].getText().toString()


Please help me find out what I am doing wrong or what I need to
change. Thank you in advance.

3. One service to rule them all

4. Wired+Wireless Tether apk

5. Resetting a HTTP InputStream...is this possible?

6. Androids on a new Cell Network

7. OOT: Mirdak di Puri Mall