> However, if either press home, or open another app in front of mine > (eg, from the notification bar) then I get the following error: >
So, if you press home or open another activity through notification, your current Activity has lost focus and invisible, so it will be call onPause() and onStop() and open the new application. When coming again to your current Activity, its calling onRestart(), onStart() and onResume(). So you need to code accordingly. Nithin On Dec 22, 4:38 am, Syx <[email protected]> wrote: > Hi, > > So I have an app that downloads and displays a list of messages. I > have two main classes that I use > - my own adapter which extends ArrayAdapter to display the list > items in a specific way > - and a mailbox class which has an ArrayList in it amongst other > things > > Both of these classes implement Serializable. In my > onSaveInstanceState method, I have the following: > > @Override > protected void onSaveInstanceState(Bundle outState) { > super.onSaveInstanceState(outState); > outState.putSerializable("savedAdapter", m_adapter); > outState.putSerializable("savedMailbox", m_mailbox); > } > > I have nothing in my onStart/onResume/onPause/onStop/onDestroy > methods. My onCreate method checks whether inState is null and does > the appropriate thing. > > So here is my problem: > > When I rotate the screen, onSaveInstanceState() saves the all three > objects, the activity is destroyed, recreated, and onCreate() extracts > them all perfectly. Great. > > However, if either press home, or open another app in front of mine > (eg, from the notification bar) then I get the following error: > > ERROR/AndroidRuntime(16961): java.lang.RuntimeException: Parcelable > encountered IOException writing serializable object (name = <my app> > $MessageAdapter) > ... > ERROR/AndroidRuntime(16961): Caused by: > java.io.NotSerializableException: <my app>$3 > > If I delete the relevant putSerializable line, then I get the same > error for Mailbox. > > Why is it behaving in different ways when they are following exactly > the same activity life cycle? > And why would it throw an NotSerializableException at all when both > classes implement serializable and work when I rotate the screen? -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android 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

