简体   繁体   English

在Android上实施位置跟踪

[英]Implementing location tracking on Android

I am new to Android development and want to build a first sample application. 我是Android开发的新手,想要构建第一个示例应用程序。 My goal is to build a tracking application which sends my current location to a remote server. 我的目标是构建一个跟踪应用程序,将我当前的位置发送到远程服务器。 I want to use the collected data to calculate how many hours I spend in well known places like home or work. 我想用收集的数据来计算我在家里或工作等知名地方花了多少小时。

Which approach should I use? 我应该使用哪种方法? I think it will be sufficient to use the information of present WLANs to get a good idea about the current location I am at. 我认为使用现有无线局域网的信息来了解我目前的位置就足够了。 All the places I am interested in have WLAN with a static SSID. 我感兴趣的所有地方都有带静态SSID的WLAN。 Are there any frameworks I should use or is there a better approach to what I am trying to do? 我应该使用任何框架,还是有更好的方法来实现我的目标? GPS is not a real option, because the most interesting places are indoors and I have no GPS connection there. GPS不是一个真正的选择,因为最有趣的地方是在室内,我没有GPS连接。

I am working on Android 4.0. 我正在使用Android 4.0。

As you say, GPS connection doesn`t work indoor, but it is very useful to estimate your current position. 正如您所说,GPS连接在室内不起作用,但估计您当前的位置非常有用。 How? 怎么样? You could use the function getLastKnownLocation(best) that provides the LocationManager. 您可以使用提供LocationManager的函数getLastKnownLocation(best)。

If you want to do it by yourself, you could try to get the last position by GPS, to locate a big area, and use the WLANs to estimate it with more accuracy, using the smaller group of radius with your interesting places. 如果您想自己动手,可以尝试通过GPS获取最后一个位置,找到一个大区域,并使用WLAN更准确地估计它,使用较小的半径组和您感兴趣的位置。

You might want to read the Making Your App Location Aware training guide on the Android developer site. 您可能需要阅读Android开发人员网站上的制作应用程序位置感知培训指南。 There's also an included sample application. 还有一个包含的示例应用程序。

I actually am working on a similar project. 我实际上正在做一个类似的项目。 Here is my code for location tracking on android; 是我在android上进行位置跟踪的代码; check it out. 看看这个。 It tracks user's location regularly, uses Network location while indoor, and GPS when it could have a fix. 它定期跟踪用户的位置,在室内使用网络位置,在可以修复时使用GPS。 It should give you a quick start. 它应该给你一个快速的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM