使用Google Play服务的Android定位

Welcome to android location using google play services example. Today we will learn how to use Google Play services API to retrieve your mobile location with example app.

欢迎使用Google Play服务示例访问Android位置。 今天,我们将学习如何通过示例应用程序使用Google Play服务API来检索您的移动位置。

Android Location API概述 (Android Location API Overview)

In the previous tutorial, we retrieved the user’s location using Android’s Location API that was available since Android’s API 1. So why was there a need for introducing Google Play Location Services? Why hasn’t Google enhanced Android’s Location API? What are the advantages of Google Play Location Services over the default Android Location API? Let’s discuss these questions to get a clear idea.

在上一教程中,我们使用了Android的位置API(自Android的API 1开始提供)来检索用户的位置。那么为什么需要引入Google Play定位服务? Google为什么没有增强Android的Location API? 与默认的Android Location API相比,Google Play定位服务有哪些优势? 让我们讨论这些问题以获得清晰的想法。

需要引入Google Play定位服务 (Need for introducing Google Play Location Services)

The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automates tasks such as location provider choice and power management. Furthermore, it provides new features such as user’s activity detection that wasn’t available in the Android Framework’s Location API. Currently, Google provides 5 user states which are In Vehicle, On Bicycle, On Foot, Still, and Tilting, which are good enough to detect user’s activity, and to provide right content according to user’s status.
Another feature it provides is Geofencing API that is used to notify a user entering or exiting a particular area.
The above advantages clearly indicate why Google Location Services API(also known as FusedLocationProviderApi) is Google’s recommended way of getting a user’s location. It provides the best accuracy based on our needs.

作为Google Play服务的一部分的Google Location Services API提供了功能更强大的高级框架,该框架可自动执行诸如位置提供商选择和电源管理之类的任务。 此外,它提供了新功能,例如Android Framework的Location API中不提供的用户活动检测。 目前,Google提供了5种用户状态,分别是“车辆内”“自行车上”“步行上” ,“ 静止 ”和“ 倾斜” ,这些状态足以检测用户的活动并根据用户的状态提供正确的内容。
它提供的另一个功能是Geofencing API ,用于通知用户进入或离开特定区域。
上述优势清楚地说明了为什么Google推荐使用Google Location Services API (也称为FusedLocationProviderApi )来获取用户位置。 它可以根据我们的需求提供最佳的准确性。

Google为什么没有增强Android的Location API? (Why hasn’t Google enhanced Android’s Location API?)

From a technical point of view, Google hasn’t improved Android’s Location API since Android has an independent update roll-out feature that lies in the hands of the smartphone manufacturer. Google has less control over it and hence decided to shift to a new API instead.

从技术角度来看,由于Android具有独立的更新推出功能(由智能手机制造商掌握),因此Google并未改进Android的Location API。 Google对它的控制较少,因此决定改用新的API。

There are few important classes that are used to get the location:

有几个重要的类可用于获取位置:

  • LocationRequest : A data object that contains quality of service parameters for requests to the FusedLocationProviderApi. LocationRequest objects are used to request a quality of service for location updates from the FusedLocationProviderApi.

    LocationRequest
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值