下面的代码使我可以随意地打开或关闭用户的GPS,但有时不能正确工作,尽管GPS扫描的图标将位于用户通知栏的屏幕顶部,GPS图标将不会被高亮显示。像(isProviderEnabled(LocationManager.GPS_PROVIDER);)这样的验证不能检测是否启用了全球定位系统。
用于启用全球定位系统的代码:
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);截图:

发布于 2014-02-17 06:12:34
参考这个链接:它的sdk版本问题。更高版本不支持这一意图。
http://iamvijayakumar.blogspot.in/2013/08/disable-gps-via-programatically-in.html
https://stackoverflow.com/questions/21821514
复制相似问题