构建位置感知应用
移动应用的其中一个独特功能是位置感知。移动用户无论走到哪里都会随身携带设备,因此为您的应用添加位置感知功能可给用户带来更契合环境的体验。借助 Google Play 服务中提供的各种地理位置 API,您可以更方便地向应用中添加自动地理位置跟踪、错误街道侧检测、地理围栏和运动状态识别等地理位置感知功能。
开发资源
请求适当的权限
根据应用功能的用例声明权限并发出请求。
接收位置信息更新
使用一体化位置信息提供程序向用户提供相关性更高的位置信息。
优化电量消耗
提高用户设备的电池能效。遵循与后台位置信息限制相关的准则。
将地图添加到您的应用中
在地图上标出感兴趣的地点,允许用户控制地图上显示的内容。
最新资讯
Headspace's Android reboot increases monthly active users by 15%
In order to launch new features on their Android app, Headspace spent 8 months refactoring their architecture and rewriting in Kotlin. Learn how this reboot helped their business grow.
SmartNews reduces lines of code by 20% and improves team morale with Kotlin
SmartNews helps millions of people discover their world everyday by sharing timely news from a diverse set of news sources.
Twitter increases developer productivity and code reliability with Kotlin
Twitter is one of the most widely used social media platforms where users can see what’s happening in the world at any given moment.
Google Home reduces #1 cause of crashes by 33%
The Google Home app helps set up, manage, and control your Google Home, Google Nest, and Chromecast devices—plus thousands of connected home products like lights, cameras, thermostats, and more.
其他资源
如需详细了解如何在应用中请求访问位置信息,请参阅下列补充资源:
Codelab
- 通过 Kotlin 在 Android 10 中获取位置信息:了解如何在搭载 Android 10 的设备上请求获取位置信息,包括在应用使用期间请求获取位置信息。