开发者

Android - When to use Service

开发者 https://www.devze.com 2022-12-29 07:09 出处:网络
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

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


I would try using a thread instead of a service.

0

精彩评论

暂无评论...
验证码 换一张
取 消