I would really discourage this.  We try very hard to keep app startup time
fast so the user doesn't need to sit there waiting for it.  If you really
have lots of expensive thing that you can't avoid doing later, I would
recommend doing that in the background after you have your app UI up rather
than making the user wait for you app.  As a general rule, a second is a
looong time to wait on a handheld device, and the user will definitely have
a more positive feeling towards something that takes a second less to start
when they launch it.

For causing an activity to load, you really don't want to call onCreate().
Any reference to its code such as accessing a static will cause the VM to
load and initialize it.

But you should first do some profiling.  It doesn't take a long time for the
VM to load an initialize a single class.  So there is probably either a lot
of work you are doing in your static initialization, or a lot of other
classes you are causing to load when your own is loaded.

On Mon, Mar 30, 2009 at 5:44 AM, Matthias <[email protected]> wrote:

>
> Hi guys,
>
> our app is getting bigger and more complicated lately, and I
> definitely noticed a loss in responsiveness and overall snappy-ness.
> Besides onCreate handlers becoming slower (we use lots of custom view
> drawables now, because the Android stock styles don't work for us
> anymore), sometimes, when a class is used for the first time, the
> Android class loader lazy loads that class which significantly slows
> down activity load times.
>
> I was therefore wondering if you know whether it's possible and common
> practice to load activities and classes which are anticipated to be
> loaded anyway during application start, e.g. by using Class.forName or
> even explicitly calling Activity.onCreate simply to already have it
> readily constructed as soon as the user actually wants to use it? A
> loading screen would be shown meanwhile.
>
> I have never seen an Android app doing this, but on the iPhone, almost
> any application goes through a loading process when starting up.
>
> Any thoughts on best practices and solutions here?
>
> Thanks for your input,
> Matthias
> >
>


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