Are you aware that an orientation change will destroy and re-create your Activity? It's documented here: http://developer.android.com/resources/articles/faster-screen-orientation-change.html
It sounds to me like your "non ui thread" is calling a handler in the Activity instance for the original orientation, which is not the same instance as is shown in the new orientation. A couple of suggestions: 1. Send Intents rather than calling raw Handlers. These should always get delivered to the current instance. 2. If your "non ui thread" should persist after the Activity is destroyed, I'd think it should be a Service instead. String On May 14, 7:44 pm, Alok Kulkarni <[email protected]> wrote: > Ok , i have succeeded in many parts of the app supporting the landscape > mode, i am now facing a major problem in case of Handlers. > I have many handlers for updating the UI . But they dont seem to work when i > change Orientation.They behave a bit werdly actually.For example, i have a > Play button which plays a song.A few set of events occur and then a handler > is called from non ui thread to update the button icon.The icon of the > button toggles to Pause as expected.Now when i change the orientaion, and do > the same activity, the icon does not update. Now when i change the > orientation again, the icon has been updated automatically? Is there any > issue in case of handlers in case of orientation change?The handlers seem to > get called when i checked using the debug mode ,but do not have any effect > it seems. > Thanks, > Alok. > > > > > > On Thu, May 13, 2010 at 9:54 PM, Alok Kulkarni <[email protected]> wrote: > > Thanks a lot guys for the information, > > I found this article > > >http://peacemoon.wordpress.com/2009/08/23/android-developing-orientat... > > 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 < > > [email protected]> wrote: > > >>http://developer.android.com/intl/de/guide/topics/fundamentals.html#a... > > >> "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 <[email protected]> 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 > >> [email protected] > >> > To unsubscribe from this group, send email to > >> > [email protected]<android-developers%2Bunsubs > >> > [email protected]> > >> > 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 [email protected] > >> To unsubscribe from this group, send email to > >> [email protected]<android-developers%2Bunsubs > >> [email protected]> > >> For more options, visit this group at > >>http://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 [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [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

