my main activity does have a static variable to the Resources. I added the meathod onDestroy and added the line res = null; Then I made sure that res = context.getResources(); is in the onRestoreInstanceState and onCreate meathods. But I am still getting the same log error and force close.
On Jul 7, 5:19 pm, Streets Of Boston <[email protected]> wrote: > Do you have static variables that reference (indirectly) an Activity > or a View? > If so, get rid of these static variables or make absolutely sure that > you clean them up (set them to null, clear cache, whatever) when the > activity's onDestroy is called. > > On Jul 7, 5:50 pm, schwiz <[email protected]> wrote: > > > actually, i just hadn't noticed, but this happens with or without the > > instanceState meathods being implemented. > > > On Jul 7, 4:08 pm, schwiz <[email protected]> wrote: > > > > thanks I have made the changes your link suggests, and my app is > > > working as expected when I switch from portrait to landscape, but now > > > when I switch back to portrait it forcecloses. The logcat is spitting > > > out all kinds of errors when this happen, most notability one that > > > says > > > android.view.WindowLeaked: activity name has leaked window > > > com.android.internal.policy.impl.phonewin...@decorview@437af970 that > > > was originally added here > > > > and another one that says > > > java.lang.IllegalArgumentException: View not attached to window > > > manager > > > > any idea why this is happening? > > > > On Jul 7, 2:49 pm, Charlie Collins <[email protected]> wrote: > > > > > That is intentional. > > > > >http://developer.android.com/reference/android/app/Activity.html > > > > > "Unless you specify otherwise, a configuration change (such as a > > > > change in screen orientation, language, input devices, etc) will cause > > > > your current activity to be destroyed, going through the normal > > > > activity lifecycle process of onPause(), onStop(), and onDestroy() as > > > > appropriate. If the activity had been in the foreground or visible to > > > > the user, once onDestroy() is called in that instance then a new > > > > instance of the activity will be created, with whatever > > > > savedInstanceState the previous instance had generated from > > > > onSaveInstanceState(Bundle)." > > > > > Have a look at onSaveInstanceState and onRestoreInstanceState - you > > > > should set your state that way. > > > > > StackOverflow has a good example of it > > > > -http://stackoverflow.com/questions/151777/how-do-i-save-an-android-ap.... > > > > > On Jul 7, 3:40 pm, schwiz <[email protected]> wrote: > > > > > > So I finally got to the point where I was ready to deploy my app to my > > > > > G1 and test it out and the first thing I noticed was that when I > > > > > change my phone to landscape view my main activity restarts and resets > > > > > all of my variables to their default settings. How can I avoid > > > > > this?- Hide quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" 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-developers?hl=en -~----------~----~----~----~------~----~------~--~---

