views:

148

answers:

3

I apologize in advance for the "newbie" nature of this question.

Here is my predicament: I'm brand new to android and developing in general. I'm using android's SDK with eclipse Galileo. I've followed several tutorials to create different layouts. I've even learned recently how to use radio buttons and verify which ones were selected. Now I need to create a service that downloads and updates an xml file within the application. I've tried to locate a simple tutorial for services on Google's developer site but so far, so bad. If they exist could somebody point me in the right direction?

On the other hand, I've been told Google's tutorials are a little out dated. Is that true? If so, are there any other tutorials that would hand-hold (and possibly over-explain) how to use a service to a true newbie for free (like google)?

Any suggestions would be appreciated.

A: 

Are you looking to upload/download local to the device or over a network connection?

Local File access should be covered by the Data Storage Tutorials The network connectivity portion of the dev guide is sparse (just lists the 2 main packages for network use), but a quick search on google finds what looks to be a good tutorial with source code: http://developerlife.com/tutorials/?p=288

Kevin Williams
Sorry for not specifying that. I'm looking for a service to download an .xml from a web page and update the device. I hope this clarifies things...
Bub
+2  A: 

There are several open source projects you can use as an examples

http://code.google.com/p/android-sky/source/browse/#svn/trunk/Sky

http://code.google.com/p/shelves/source/browse

http://code.google.com/p/apps-for-android/

and book by commonsware and examples to this book :

http://commonsware.com/

http://github.com/commonsguy

Alex Volovoy
Specifically, here is an example that uses a service to fetch some fairly awful XML from the US National Weather Service: http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/
CommonsWare
A: 

I would use Java's NIO for that.

A very good example (but maybe a bit complicated at first) in this test application. See these methods: download() and specifically fastChannelCopy().

You can look at a complete DownloadFile class of the very same technique here.

About the Service itself, others have pointed nice howto.

Rorist
I appreciate the references...I do have a question though. I really want this service to run in the "background" and run at a given time or based on a certain parameter independent of the app itself. I thought this could only be done with a service. Am I mistaken?
Bub
I never used it, but there is the AlarmManager for that: http://developer.android.com/intl/fr/reference/android/app/AlarmManager.html
Rorist
So you may use a Service if you want it to be transparent to the user, or an Activity if you want to be visible.
Rorist