Thursday, May 20, 2010

Re: [android-developers] Re: Maintaining the state when changing the orientation

Hi guys , thanks for the replys,
@Sanjay , i have taken care in case of ArrayAdapter for ListViews
I could successfully do save the state of application and also the handlers problem was solved. What i did is that i used a Main class which extends Application, whenever onCreate of my Activity gets called , i assign the Activity reference to a Main class Activity variable.This happens each time onCreate is called.
@JP, Actually the application is very huge currently. So i will slowly move towards Service implementation, but for current releases i need to do changes in the current architecture itself.
But currently i am  facing the issue of going OutOfMemory if i keep on changing the layout from landscape to portratit and vice versa.
I have to take all the drawable images from a runtime folder under my application as i have themes implementation and themes images come from server. So i assign drawables at runtime to all the widgets.
When the orientation changes , i reassign the drawables to all widgets.I have taken care of making the objects null.. And  views get null when onDestroy is called. Also i havent kept the reference of activity anywhere after onDestroy is called.. IS there anything wrong thats striking to anyone right now ?
Thanks ,
Alok.

On Thu, May 20, 2010 at 5:42 AM, JP <joachim.pfeiffer@gmail.com> wrote:


On May 14, 2:54 am, Alok Kulkarni <kulsu...@gmail.com> wrote:
> I need to save many objects so basically onSavedInstanceState is not of full
> use .

Like in your case, I have apps that need to keep (hundreds of) objects
and state variables that require retention regardless of what's going
on at the UI level. What I've done in order to pick up where I left
off after a rotation change (or, for that matter, when the user calls
the app from the main screen) is to start and bind a Service that I
bind again when the app comes out at the other end. Implement getters
and setters like you normally would to access the relevant data. The
SDK contains a pretty good example how to do all that which you can
use as a blueprint.
The downside is that there's a risk the service gets killed as the
system is scraping for resources, but personally I haven't seen this
happen for a service that's bound to an UI thread. There's people on
the list who know much more about what's going on under the hood in
that regard, perhaps they can chime in.

--
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+unsubscribe@googlegroups.com
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment