0

This question is related to my previous question: 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

Community
  • 1
  • 1
Chris
  • 545
  • 1
  • 10
  • 17

1 Answers1

2

I would try using a thread instead of a service.

Kinze
  • 3,780
  • 5
  • 21
  • 15
  • 1
    Better yet, use an `AsyncTask`. Whether you choose to manage that `AsyncTask` with a `Service` or not is up to you. – CommonsWare May 07 '10 at 18:15