Android 启用和禁用 GPS

Android Enable and Disable GPS(Android 启用和禁用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)