views:

125

answers:

1

This question is related to my previous question: http://stackoverflow.com/questions/2786720/android-service-ping-url

So I have an Android app that on the click of a button, opens up a web page. Now, in the background I want to call another http url for gathering stats.

My question is does this have to be a service? I know a service is for background tasks that run for an indefinite period of time, while the user is busy doing something else. In my case, all I really need is to get the URL in the background, not show it to the user, instead show the web page to the user.

Can I just not write code to get contents of the http url and fire up the activity that displays the web page? Coz all I want is to get the url in the background and be done with it. Or does this have to be done using the Service class?

I am confused.

Thanks Chris

+1  A: 

I would try using a thread instead of a service.

Kinze
Better yet, use an `AsyncTask`. Whether you choose to manage that `AsyncTask` with a `Service` or not is up to you.
CommonsWare