在 Android 3.1 及更高版本中自动开启定位服务
Turn on location services automatically in Android 3.1 and above
我知道从 android 3.1 及更高版本开始,您将无法手动打开定位服务。但在 Google 地图中,它只是显示一个对话框,提示我将其打开。这直接将其打开(在 android 5.1 - Lollipop 中)。那么google是怎么做到的呢?我可以使用某些 Google 定位服务 API 还是应该将用户引导至定位服务设置屏幕?
谢谢
他们正在使用显示如何使用此 API 的 SettingsApi It allows you to check if the location services are available on the device and there is a complete example provided by google on github。如果关闭,示例代码将提示用户启用位置。触发 Intent 时弹出的对话框与您在 Google 地图中看到的类似。
我知道从 android 3.1 及更高版本开始,您将无法手动打开定位服务。但在 Google 地图中,它只是显示一个对话框,提示我将其打开。这直接将其打开(在 android 5.1 - Lollipop 中)。那么google是怎么做到的呢?我可以使用某些 Google 定位服务 API 还是应该将用户引导至定位服务设置屏幕? 谢谢
他们正在使用显示如何使用此 API 的 SettingsApi It allows you to check if the location services are available on the device and there is a complete example provided by google on github。如果关闭,示例代码将提示用户启用位置。触发 Intent 时弹出的对话框与您在 Google 地图中看到的类似。