Android Enable and Disable GPS(Android 启用和禁用 GPS)
问题描述
可能重复:
像Tasker一样以编程方式启用GPS
我是一名初级安卓开发者.
I'm a beginner android developer.
我想通过单击一个按钮来启用和禁用 GPS,而不运行此意图:
I want enable and disable GPS with a click of a button, without running this intent:
intente in = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(in);
这让我进入了设置菜单.
that brings me in the setting menu.
有没有一种方法可以像在 android电源控制"小部件中那样启用或禁用 GPS?
Is there a method to enable or disable GPS as in the android "Power Control" widget?
谢谢
我说的小部件在 android 系统中(版本 1.6 向前).有一个应用程序(siriusapplications.com/powercontrolplus)可以让我想做,并扩展android电源控制..我的问题是:这个人如何管理这个?——
The widget that I said is in the android system (version 1.6 on forward). There is an application (siriusapplications.com/powercontrolplus) that make want I want do, and extend the android power control.. my question is: how this persor can manage this?? –
推荐答案
我不认为有办法这样做.请参阅此问题.您还可以在这里找到一个很好的例子.基本上你要做的是测试是否启用了 GPS,然后将用户导航到相应的设置页面.
I don't think there is a way to do so. See this question. You can also find a nice example here. Basically what you do is test if GPS is enabled and then navigate user to the appropriate settings page.
您所指的小部件可能可以直接访问 GPS 驱动程序.这意味着它只能在手头的设备(或单个设备系列)中工作.
The widget you are referring to probably has direct access to the GPS driver. This means that will only work in the device at hand (or in a single family of devices).
这篇关于Android 启用和禁用 GPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android 启用和禁用 GPS


- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01