2014-02-25 73 views
0

我正在开发一款应用程序,可以记录用户通过一天的位置,以便应用程序可以找出用户的近似生活方式。应用程序必须以一定的时间间隔在后台收集数据,所以我需要一个最佳策略来调用android的位置管理器的位置更新请求。但它必须在电池方面进行优化,并在精度方面保持平衡。全天记录用户的位置/移动

现在在我心中流,

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 

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

回答

2

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

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

我建议你看看被动模式,它允许你在没有通过使用其他应用程序请求进行修复的情况下获得位置。

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

gps tutorial

希望它能帮助!