启用GPS编程机器人(无导航到位置设置) [英] Enable GPS programatically Android (without navigating to the location settings)

查看:152
本文介绍了启用GPS编程机器人(无导航到位置设置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常普遍的问题,但必须有一个以编程方式启用GPS,因为它仅通过点击打开选项,弹出屏幕上出现在官方的谷歌地图应用程序(不导航到位置设置)。 有人可以帮忙吗?

This might be a very common question, however there has to be a way to enable GPS programmatically, as it does happen in the official Google Maps app by just clicking on the 'turn on' option on the pop up screen (without navigating to location settings). Can someone help?

推荐答案

在谷歌地图应用程序使用的是现在提供给我们的 SettingsApi 在播放服务SDK的7.0.0。您可以使用 SettingsApi 来询问是否您需要的 LocationRequest 可实现与任何位置启用提供商。如果无法实现,即用服务认为用户可以改变这一点,你可以要求你看到的地图显示弹出对话框。

The Google Maps app is using what is now available to us as SettingsApi in 7.0.0 of the Play Services SDK. You can use SettingsApi to inquire as to whether your desired LocationRequest can be fulfilled with whatever location providers are enabled. If it cannot be fulfilled, and Play Services thinks that the user can change this, you can ask for the dialog that you see Maps display pop up.

使用 SettingsApi 不是特别简单的。我刚刚张贴一个示例应用程序了解,昨天,从版本6.6 我的书。使用 ACTION_LOCATION_SOURCE_SETTINGS ,如Laurenswuyts的回答暗示,是的的容易实现。

Using SettingsApi is not especially simple. I just posted a sample app for that yesterday, from Version 6.6 of my book. Using ACTION_LOCATION_SOURCE_SETTINGS, as suggested in Laurenswuyts' answer, is much simpler to implement.

这篇关于启用GPS编程机器人(无导航到位置设置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆