提示用户启用 GPS

Prompting User to Enable GPS

如有错误请指正:

1) 您无法在所有版本的 Android 上以编程方式打开 GPS On/Off。也许是一些以前的版本和一些 hack,但不是在所有设备上。根本不允许。

这只剩下两个选项:

1) 使用新的 Google Play 服务提示用户更改这些设置。 一个问题是如果您只想允许用户打开 GPS, 但不是WIFI?解析器将为他们提供打开两者的选项。如何 你能只打开一个而不打开另一个吗?

2) 通过触发 Intent 将用户发送到设置应用程序。

现在 1) 用户必须安装当前 google 播放服务。 如果没有,系统会提示他们通过标准 GPS 对话框进行安装。

好的,现在 2) 将用户发送到设置应用程序。我有以下问题:

当我发出这个意图时,他们不仅可以更改 Location/GPS 设置,还可以点击“设置”应用中的小后退按钮,并调整所有设置。有什么办法可以防止这种情况发生吗?无论如何要在没有内部后退按钮的情况下调出 Location/GPS 设置?谢谢。

You cannot programatically turn GPS On/Off on all versions of Android. Maybe some previous versions, and some hacks, but not on all devices. It simply is not allowed.

正确,出于明显的隐私原因。

When I fire off this intent, they not only get to change the GPS Settings but they can also hit the little back button within Settings app, and adjust all settings. Is there any way to prevent this?

没有