记录用户全天的位置/运动

时间:2014-02-25 08:45:21

标签: android location

我正在开发一款可以记录用户位置的应用程序,因此应用程序可以找到用户的大致生活方式。应用程序必须以某种间隔在后台收集数据,因此我需要一个最佳策略来调用Android的LocationManager的位置更新请求。但它必须在电池方面进行优化,并在准确性方面保持平衡。

现在我心中的流动是,

iterate through the location providers, give higher priority to NETWORK (as it consumes less power), o this for each,
  get the last known location
  get the current loction
  chek if current is better than last
       if yes make this the best estimate, otherwise get location from other provider

我知道两个参数可以决定何时调用位置更新请求,

minimum interval
minimum distance

首先我会给他们一些默认值但是这些必须稍后通过使用用户的位置历史并考虑其他因素来更新

  reduce the frequency of update request if battery is < 75% and further reduce it when   
  battery is  < 50%
  increase frequency of update request when user is moving fast (Activity Recognition Class   
  from google location services can help here)
  if we predict the time windows in which user does not move (from history), decrease the  
  frquency of location updates
  use GPS minimal time because it consumes more battery

所以这些是我想到的部分,但它现在看起来像一团糟,因为它没有很好的结构。因此,如果有人可以帮助我添加更多内容或者可以建议一些更好的策略(电池必须优化),我会非常感激并且它很长,所以如果你认为我浪费了你的时间请控制你的情绪。谢谢

1 个答案:

答案 0 :(得分:2)

为了获得良好的准确性,Google提供的算法在我看来提供了良好的结果。你可以在那里找到它:reference

GPS需要时间来修复,我会说大约一分钟(取决于设备)。

我建议您查看被动模式,它允许您通过使用其他应用程序请求而无需修复即可获得位置。

  

passive:一种特殊的位置提供程序,用于接收位置而无需实际启动位置修复。当其他应用程序或服务请求时,此提供程序可用于被动地接收位置更新,而无需自己实际请求位置。此提供程序将返回其他提供程序生成的位置。需要权限android.permission.ACCESS_FINE_LOCATION,但如果未启用GPS,则此提供程序可能只返回粗略修复。

gps tutorial

希望它有所帮助!