Currently i am having handlers in my code which update th ui. But it seems they are not having any effect on ui when i change the orientation.the handlers get called but do not have any effect on ui.is there any special handling that needs to be done in case of handlers?
On 5/14/10, Alok Kulkarni <kulsu...@gmail.com> wrote: > Thanks a lot guys for the information, > I found this article > http://peacemoon.wordpress.com/2009/08/23/android-developing-orientation-aware-android-applications/ > I need to save many objects so basically onSavedInstanceState is not of > full > use . > So i am going forward with onRetainNonConfigurationInstance(). > @Charlie, why is this method not so reliable? > Thanks, > Alok. > On Fri, May 14, 2010 at 6:25 AM, Charlie Collins > <charlie.coll...@gmail.com>wrote: > >> http://developer.android.com/intl/de/guide/topics/fundamentals.html#actlife >> >> "Saving activity state >> >> When the system, rather than the user, shuts down an activity to >> conserve memory, the user may expect to return to the activity and >> find it in its previous state. >> >> To capture that state before the activity is killed, you can implement >> an onSaveInstanceState() method for the activity. Android calls this >> method before making the activity vulnerable to being destroyed — that >> is, before onPause() is called. It passes the method a Bundle object >> where you can record the dynamic state of the activity as name-value >> pairs. When the activity is again started, the Bundle is passed both >> to onCreate() and to a method that's called after onStart(), >> onRestoreInstanceState(), so that either or both of them can recreate >> the captured state. >> >> Unlike onPause() and the other methods discussed earlier, >> onSaveInstanceState() and onRestoreInstanceState() are not lifecycle >> methods. They are not always called. For example, Android calls >> onSaveInstanceState() before the activity becomes vulnerable to being >> destroyed by the system, but does not bother calling it when the >> instance is actually being destroyed by a user action (such as >> pressing the BACK key). In that case, the user won't expect to return >> to the activity, so there's no reason to save its state. >> >> Because onSaveInstanceState() is not always called, you should use it >> only to record the transient state of the activity, not to store >> persistent data. Use onPause() for that purpose instead." >> >> http://developer.android.com/intl/de/reference/android/app/Activity.html >> >> "Configuration Changes >> If the configuration of the device (as defined by the >> Resources.Configuration class) changes, then anything displaying a >> user interface will need to update to match that configuration. >> Because Activity is the primary mechanism for interacting with the >> user, it includes special support for handling configuration changes. >> >> 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). >> >> This is done because any application resource, including layout files, >> can change based on any configuration value. Thus the only safe way to >> handle a configuration change is to re-retrieve all resources, >> including layouts, drawables, and strings. Because activities must >> already know how to save their state and re-create themselves from >> that state, this is a convenient way to have an activity restart >> itself with a new configuration. >> >> In some special cases, you may want to bypass restarting of your >> activity based on one or more types of configuration changes. This is >> done with the android:configChanges attribute in its manifest. For any >> types of configuration changes you say that you handle there, you will >> receive a call to your current activity's >> onConfigurationChanged(Configuration) method instead of being >> restarted. If a configuration change involves any that you do not >> handle, however, the activity will still be restarted and >> onConfigurationChanged(Configuration) will not be called." >> >> That should get you going in the right direction. There is also >> onRetainNonConfigurationInstance (Activity method) but it's not what >> you should rely on (can be used to optimize), but the basics are the >> onSaveInstanceState and onRestoreInstanceState methods. >> >> >> On May 13, 4:29 am, Alok Kulkarni <kulsu...@gmail.com> wrote: >> > I am having an application showing ListItems and Dialog boxes in it.. >> > I want that when i change the orientation from Portrait to landscape >> mode, i >> > need to maintain the state of the application .. I have seperate XMLs >> > for >> > landscape and portrait mode.. >> > What is the best way to achieve this > >> > Thanks , >> > Alok. >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Android Developers" group. >> > To post to this group, send email to >> > android-developers@googlegroups.com >> > To unsubscribe from this group, send email to >> > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> >> > For more options, visit this group athttp:// >> groups.google.com/group/android-developers?hl=en >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > -- Sent from my mobile device -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en