背景工艺扫描定期用户的位置,并更新本地数据库,即使当应用程序是不开放应用程序、背景、位置、不开放

2023-09-07 08:36:52 作者:洒脱做人

我创建一个应用程序,检查每半小时一班的用户的位置,并更新本地数据库中的用户的位置,然后运行的基础上,即使当应用程序没有运行用户的位置CRUD查询。我该怎么做呢?

I am creating an app that checks for user locations every half an hour and updates the location of the user in the local database and then runs CRUD queries based on the user's location even when the app is not running. How do i do it ?

我已经提到这个http://techtej.blogspot.com.es/2011/03/android-thread-constructspart-4.html文章,我仍然感到困惑的是正确的做法对我的结果?

I have referred to this http://techtej.blogspot.com.es/2011/03/android-thread-constructspart-4.html article and i am still confused about which is the correct approach for my result ?

有根据文章的4个选项我打算根据我实现

There are 4 options according to the article for what i intend to achieve according to me

1)服务:但是,因为我觉得这会是一个漫长的操作与本地数据库,我觉得我应该忽略这一项

1) Service : But since i feel it would be a long operation with the local database, i feel i should ignore this one.

2)IntentService:这不能执行多任务,所以我觉得这其中也应该避免对我来说,因为我必须得到用户的位置,并扫描数据库,更新数据库(3个任务)

2) IntentService : This cannot perform multiple tasks, so i feel this one also should be avoided for me as i have to get the location of the user and scan the database , update the database (3 tasks)

3)主题:我不知道如何调用该应用程序时未打开

3)Thread : I am not sure how to call this when the app is not open

4)AsyncTask的:我不知道如何调用该应用程序时未打开

4) AsyncTask : I am not sure how to call this when the app is not open.

基本上我在寻找类似的东西在本地数据库,同时工作的位置数据运行的cron作业。

Basically i looking for something like a CRON JOB that runs on a local database while working on the location data.

这将是巨大的,如果你能联系我的一些教程,并回答一个简单的例子,让我了解所有4种方法的差异。

It would be great if you could link me up to some tutorials and answer with a simple example to make me understand the difference of all 4 methods.

// editted 3月16日: 我看过一些关于它的API 21推出的jobscheduler,但不知道这是否也支持到姜饼是正确的做法我的问题

// editted on 16 March : I have read something about a JobScheduler which is introduced in the API 21, but not sure if it also supports till Gingerbread and is it the right approach for my question

感谢名单

推荐答案

在记录用户位置,使用服务与通知。只是为了建立一个道德上负责任的应用程序,通知应用程序正在跟踪他们的用户。根据定义的服务在后台运行。

When recording the users position use a service with a notification. Just for the sake of creating a morally responsible app that informs the user the app is tracking them. The service by definition runs in the background.

一个融合的位置提供与的setInterval(长)