如何在Android中以编程方式启动GPS ON和OFF [英] How to start GPS ON and OFF programatically in Android

查看:230
本文介绍了如何在Android中以编程方式启动GPS ON和OFF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发GPS应用程序。所以我需要自动打开和关闭gps。

当我的代码启动gps但不会自动关闭。

请帮助我。

解决方案

您好,



请查看这个 [ ^ ]线程。



请注意,此线程上推荐的某些解决方案不适用于Android OS帖子2.3。



问候,


如果上面的代码不起作用,试试这个。但是你还需要记住在某些设备上打开/关闭gps时遇到一些问题。试试你喜欢的东西..

  //  启用GPS  
意图意图= 意图( android.location.GPS_ENABLED_CHANGE);
intent.putExtra( enabled,true);
sendBroadcast(意图);
// 禁用GPS
意图意图= new Intent( android.location.GPS_ENABLED_CHANGE);
intent.putExtra( enabled,false);
sendBroadcast(意图);


试试这个...... :)



http://stackoverflow.com/questions/4721449/enable-gps-programatically-like-tasker [ ^ ]

i develop GPS application. so i need turn on and off gps automatically.
when my code start gps ones but not turn off automatically.
Please help me.

解决方案

Hello,

Please have a look at this[^] thread on StackOverflow.

Please note that some of the solutions recommended on this thread won't work on Android OS post 2.3.

Regards,


Try this if above code won't work.But you need to remember still there may be some problem on turning gps on/off on some devices.So try what you suit..

//Enable GPS
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
//Disable GPS
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", false);
sendBroadcast(intent);


Try this...:)

http://stackoverflow.com/questions/4721449/enable-gps-programatically-like-tasker[^]


这篇关于如何在Android中以编程方式启动GPS ON和OFF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆