安卓4.1.2如何关闭GPS编程 [英] Android 4.1.2 How to turn off GPS programmatically
本文介绍了安卓4.1.2如何关闭GPS编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过code对GPS进行切换。以下是code我用。
I am trying to switch on GPS by code. The following is the code I've used.
String provider = Settings.Secure.getString(context.getContentResolver(),Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider.contains("gps")){ //if gps is enabled
final Intent poke = new Intent();
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
context.sendBroadcast(poke);
在code执行中的onReceive功能。我究竟做错了什么?
The code executing in OnReceive function. What am I doing wrong?
推荐答案
Android的指导方针在4.0以上版本的改变。您不能以编程方式更改GPS关闭在4.0以上的版本。但是,您可以以编程方式更改WiFi关闭
Android Guidelines have changed above version 4.0. You cannot change GPS off on programmatically for versions above 4.0. However, you can change wifi off on programmatically
这篇关于安卓4.1.2如何关闭GPS编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文