我应该使用的AsyncTask或IntentService我的应用程序?我的、应用程序、AsyncTask、IntentService

2023-09-03 20:59:53 作者:残留的记忆还在

我一直在读围绕互联网连接与Android,发现有不同的方式来处理这也就是AsyncTask的和IntentService。不过,我仍然不知道哪一个使用。我的应用程序基本上是一个位置/路径查找器与谷歌地图。我的互联网连接性将被用来查找映射的一个特定半径范围内最接近的路径。这样,每一个用户移动或刷卡地图到新位置的时间,然后,将与最接近的路径更新。这也将增加一个新的线索,并允许用户速率的线索。

I have been reading around on internet connectivity with Android and noticed there are different ways to handle this i.e. AsyncTask and IntentService. However, I'm still not sure which one to use. My application is basically a location/trails finder with Google Maps. My internet connectivity will be used to find the nearest trails within a certain radius of the map. So, every time a user moves or swipes the map to a new location then it will update with the nearest trails. It will also add a new trail, and allow the user to rate a trail.

威尔的AsyncTask满足这个还是我应该使用IntentService?

Will AsyncTask suffice for this or should I use IntentService?

推荐答案

您应该使用的AsyncTask 对于紧密绑定到一个活动的短期重复性的任务,就像你重目前正在努力做的事情。 IntentService 是对计划任务的详细齿轮(重复或没有)应该运行在后台,独立的活动。

You should use an AsyncTask for short repetitive tasks that are tightly bound to an activity, like what you're currently trying to do. IntentService are more geared towards scheduled tasks (repetitive or not) that should run on the background, independent of your activity.