Please reread the doc carefully. You can run stuff on the UI thread in three
of the methods. There's really no need to send a message if you make the
subclass of AsyncTask an inner class. In that case those three methods can
do anything on the enclosing Activity's behalf, like setting the contents of
a view or showing a dialog.

On Thu, Jan 21, 2010 at 3:22 PM, Flapjack <[email protected]> wrote:

> According to my research, which includes reputable sources (Mark
> Murphy et al), the most preferred way of polling a remote source and
> presenting said data to the user is by creating a service and using
> AsyncTask within that service to do the polling. I have done that.
>
> But, when I read the docs (http://developer.android.com/reference/
> android/os/AsyncTask.html), there seem to be several "Threading Rules"
> that conflict with this way of doing things: "The task instance must
> be created on the UI thread." and "execute(Params...) must be invoked
> on the UI thread." As stated, I have created the task instance on the
> Service thread (not the UI thread). Am I missing something?
>
> Also, when the AsyncTask finished, I sent out a Broadcast on
> onPostExecute, which is then picked up by the Activity, telling it to
> retrieve the final value again from the service (since I couldn't
> obviously update the UI from the service). I couldn't figure out any
> other way to return the result of the AsyncTask. Is this the correct
> practice?
>
> Java is not my native language so please bear with my ignorance.
> Thanks!
>
> --
> 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


Please

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