You can use this to efficiently propagate instantiated objects across these
instances:

http://developer.android.com/reference/android/app/Activity.html#onRetainNonConfigurationInstance()

Do make sure that none of the objects hold a reference on the current
activity/context, or you will cause that to leak.

On Thu, Dec 17, 2009 at 1:08 PM, TreKing <[email protected]> wrote:

> Save your objects to the bundle in onSaveInstanceState and in onCreate()
> check if the incoming bundle is null. If it is, load from file, if it's not,
> load your saved data from the bundle.
>
> Honestly though, if you're not really saving state information and loading
> from files in onCreate isn't taking that long for you, you're just wasting
> time and adding complexity to your app.
>
>
>
> -------------------------------------------------------------------------------------------------
> TreKing - Chicago transit tracking app for Android-powered devices
> http://sites.google.com/site/rezmobileapps/treking
>
>
> On Wed, Dec 16, 2009 at 1:15 PM, ailinykh <[email protected]> wrote:
>
>> In my application onCreate method reads some files, creates a bunch of
>> objects (Model) and then
>> creates visual layout. When an orientation gets changed it reads files
>> again. But they are the same.
>> There is no need to read them again. Only visual layout needs to be
>> recalculated.
>> Is there a way to avoid this extra job?
>>
>> Thank you,
>>  Andrey
>>
>> On Dec 15, 12:26 pm, Mark Murphy <[email protected]> wrote:
>> > steff wrote:
>> > > But my problem is this (at this point my misunderstanding kicks in):
>> > > whenever I rotate the device the onCreate(), onStart() etc. methods
>> > > are called, causing my app to act as if it just started.
>> >
>> > Correct. By default, on an orientation change, Android destroys and
>> > recreates your activity, to map in the appropriate layout resources and
>> > such.
>> >
>> > --
>> > Mark Murphy (a Commons Guy)http://commonsware.com|
>> http://twitter.com/commonsguy
>> >
>> > _Android Programming Tutorials_ Version 1.0 Available!
>>
>> --
>> 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%[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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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

Reply via email to