Thanks for the reply again. It was quite helpful. I am actually
downloading small audio files for an answering machine app. If the
activity that launched the service is still running, I would like it
to update to include the newly downloaded files in the UI for the user
to listen to. If the user has moved to a different activity, I just
want the service to save the file to persistent storage. (It will
store to persistent storage either way, but if the activity is running
the UI should update) A service seems appropriate here although I am
certainly open to other options?

I understand that I can get a reference to the service from the
activity, and how I could pass information with it. The issue I am
having specifically is notifying the activity that the download is
complete. I would really rather avoid having the activity poll the
service to find out if the download is completed.



On Feb 7, 9:53 pm, TreKing <[email protected]> wrote:
> On Mon, Feb 7, 2011 at 8:35 PM, Avtar Khalsa <[email protected]> wrote:
> >  However, the local service example and the class you specifically referred
> > to only seem to accommodate messages from the service onServiceConnected
> > and onServiceDisconnected.
>
> Those are the explicit events the ServiceConnection get. Notice in the
> example when the service is started, the connection object grabs a reference
> to the Service. The ServiceConnection itself is referenced in the Activity.
> Therefore you can get at the Service reference from your Activity through
> the ServiceConnection.
>
> > This does not really help me since my activity will be launching the
> > service and then will need the service to notify it once the information
> > from my server has been successfully downloaded.
>
> Services are usually for maintaining an ongoing background task. Binding to
> them is usually for showing the state of that background task to the user
> (and possibly give them control over it). Think "music player".
>
> If you're just trying to download some data while your Activity is alive, an
> AsyncTask within your Activity may be much, much simpler.
>
> --------------------------------------------------------------------------- 
> ----------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

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