When you switch from portrait to landscape mode or vice-versa, your activity's onDestroy() and onCreate() will be called.
-- Jack Ha Open Source Development Center ・T・ ・ ・Mobile・ stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Jul 2, 7:13 am, csyperski <csyper...@dupage88.net> wrote: > I have a very simple app activity within an app where there is a > single Buttton and an Edit Text used for a user to enter a pin code. > Here is my issue, everything works great if the app is kept in > portrait mode, but if the screen is rotated to landscape mode it seems > like another instance of the activity is being pushed onto the stack, > because if you enter the valid pin code the activity does a: > > setResult( RESULT_OK ); > finish(); > > But returns to (what seems) another instance of the same activity but > with the text field cleared. Maybe I am just not understanding that > is happening in the activity lifecycle here, if someone could shed > some light? Below is the bulk of the code: > > private SharedPreferences prefs; > private String strPin; > > protected void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > setContentView(R.layout.andpinlogin); > prefs = PreferenceManager.getDefaultSharedPreferences > (this); > > Button btn = (Button)findViewById(R.id.Button01); > btn.setOnClickListener(this); > > strPin = prefs.getString("pin", ""); > } > > @Override > public void onClick(View arg0) > { > if( arg0 instanceof Button ) > { > EditText txt = > (EditText)findViewById(R.id.EditText01); > if ( txt != null ) > { > String strText = txt.getText().toString(); > if ( strText != null ) > { > if ( > strText.trim().compareToIgnoreCase(strPin)==0) > { > setResult( RESULT_OK ); > finish(); > } > else > { > Toast.makeText(this, "Invalid > pin code", Toast.LENGTH_LONG).show > (); > } > } > } > > } > } > > Thanks again to anyone that can help me out! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---