You absolutely should not be doing networking or (major) disk IO on the main
thread, as has always been the case.  HC has the new Loader API to help with
this, and of course there as been AsyncTask for a long time, etc.

On Tue, Feb 15, 2011 at 6:19 PM, davemac <[email protected]> wrote:

> Okay. I can accept that waiting until onActivityCreated() doesn't make
> a significant difference. But I still shouldn't be doing disk I/O or
> network accesses on the UI thread, right? On Honeycomb, a network
> access on the UI thread is fatal (see Brad's blog post on StrictMode).
> So I have to create a background thread if I want to get data when my
> application starts. Yes I will need to use messaging to notify my
> activity that the data is ready to be consumed. I'll now be prepared
> to wait until after onResume() to expect those messages. Thank you for
> the answer. This is very helpful information.
>
> - dave
>
> On Feb 15, 8:48 pm, Dianne Hackborn <[email protected]> wrote:
> > This really won't gain you anything.  The time between onAttach() and
> > onActivityCreated() is the time your activity spends in onCreate().
> >
> > On a dual core CPU, maybe you will be able to get a little more work
> done.
> >  Maybe.  On a single core, there is only one CPU available, there are no
> > pauses going on during this, so the CPU is already in full use.
> >
> > Another point -- if you are doing work on another thread, you will
> probably
> > be sending a message back to the main thread with its result.  If you
> think
> > onActivityCreated() is late, the time until the main thread actuallly
> goes
> > back to process the next message in the queue is way way way late, after
> > everyone has gone through onResume().
> >
> >
> >
> > On Tue, Feb 15, 2011 at 4:06 PM, davemac <[email protected]> wrote:
> > > There are quite a few callbacks associated with a fragment. The sample
> > > programs I've seen so far use simple, local string and resource data
> > > in onActivityCreated(), which seems late to me. Would there be any
> > > problem with spinning off a thread, or AsyncTask, or equivalent, as
> > > early as onAttach(), or even in onInflate() to go get data from disk
> > > or over the network? Then by the time onActivityCreated() is called,
> > > the data might be ready, and if not, I could just leave placeholders
> > > in the UI until the data comes back. Any advice from the Android team
> > > please? Thanks.
> >
> > > P.S. Sorry if this looks like a re-post. It is, but I can't see my
> > > previous post at all. It just disappeared.
> >
> > > --
> > > 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
> >
> > --
> > 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
>



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