Hello
I have recently began working with android and the life cycle is still
a bit confusing, i have a test activity that simply counts the number
of mouse clicks on a screen. to test it i navigate out of the activity
( by pressing home ) and most of the times i return to the application
onCreate is called, but a few times it  is not, and i do not
understand why. secondly I cannot seem to save the state of the
activity, i have read a few posts here and i read that onSavedInstance
will not be called if you navigate out of the activity, but if it is
not called, shouldn't the state of my variables persist ? Below is a
part of the code, any help/clarification
is greatly appreciated !


        @Override
        public void onCreate( Bundle savedInstanceState )
        {
                super.onCreate( savedInstanceState );
                setContentView( R.layout.main );

                Button button = (Button) findViewById( R.id.button );
                button.setOnClickListener( listener );

                numberOfclicks = savedInstanceState != null ?
savedInstanceState.getInt( NUMBER_OF_CLICKS ) : 0;
        }

        @Override
        protected void onSaveInstanceState( Bundle outState )
        {
                outState.putInt( NUMBER_OF_CLICKS, numberOfclicks );
                super.onSaveInstanceState( outState );

        }

I have debugged it and onSaveInstanceState is being called ...

Cheers

Guilherme Melo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to