如何启用和禁用编程GPS [英] How can i enable and disable GPS programatically
本文介绍了如何启用和禁用编程GPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发一个应用程序,其中我想启用GPS,当我开始我的活动,我想禁用GPS,当我离开我的应用程序。我可以通过我的节目做..
I am developing an application wherein I want to enable GPS, when I start my activity and I want to disable GPS when I exit my application. Can I do it through my program..
任何帮助将是AP preciated。
Any help would be appreciated.
推荐答案
下面是code ...
Here is the code...
private void turnGPSOn(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(!provider.contains("gps")){
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"));
sendBroadcast(poke);
} }
这篇关于如何启用和禁用编程GPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文