public boolean isLocationEnabled() {
int locationMode = 0;
String locationProviders; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
locationMode = Settings.Secure.getInt(getActivity().getContentResolver(), Settings.Secure.LOCATION_MODE); } catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return false;
} return locationMode != Settings.Secure.LOCATION_MODE_OFF; }else{
locationProviders = Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
} }

[android]判断位置服务是否打开的更多相关文章

  1. android判断adb调试是否打开及代码跳转到开发者选项界面

    boolean enableAdb = (Settings.Secure.getInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0) &g ...

  2. Android 判断是否联网 是否打开上网

    ConnectivityManager cwjManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); ...

  3. Android判断网络是否打开,并打开设置网络界面

    由于Android的SDK版本不同所以里面的API和设置方式也是有少量变化的,尤其是在Android 3.0 及后面的版本,UI和显示方式也发生了变化,现在就以打开网络设置为例,同大家分享一下: 1. ...

  4. 与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器

    原文:与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器 [索引页][源码下载] 与众不同 windows phon ...

  5. Android 位置服务

    原文来自:http://developer.android.com/guide/topics/location/strategies.html 位置策略 注意: 本指南仅限android.locati ...

  6. Android实现传感器应用及位置服务

    Android实现传感器应用及位置服务 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 代码实现 这里需用获取加速度传感器和地磁传感器,手机获取旋转的方 ...

  7. [译]:Xamarin.Android平台功能——位置服务

    返回索引目录 原文链接:Location Services. 译文链接:Xamarin.Android平台功能--位置服务 本部分介绍位置服务以及与如何使用位置提供商服务 Location Servi ...

  8. 【Android】第18章 位置服务和手机定位—本章示例主界面

    分类:C#.Android.VS2015: 创建日期:2016-03-04 一.简介 目前,基于位置的服务发展迅速,已涉及到商务.医疗.定位.追踪.敏感区域警告.工作和生活等各个方面.定位服务融合了G ...

  9. Android 位置服务——BaiduLocation的使用

    原文:Android 位置服务--BaiduLocation的使用 版权声明:本文为博主原创文章,欢迎转载,转载请在文章显眼处说明文章出处并给出连接. https://blog.csdn.net/To ...

随机推荐

  1. java布局学习 (二)

    前文中介绍了FlowLayout和BorderLayout 本文我们将会继续介绍java中的布局方式 (3)GridLayout 网格布局 这种布局会将整个容器划分成M行*N列的网格. 如下图:    ...

  2. Java:回调机制

    引用:http://blog.sina.com.cn/s/blog_48cf38890100go6x.html 1.  什么是回调函数    回调函数(callback Function),顾名思义, ...

  3. Recover lost Confluence password

    confluence重置admin密码 复方法: 1. 运行此sql 找到你的管理员帐户: select u.id, u.user_name, u.active from cwd_user u joi ...

  4. Html5的表单

    跨浏览器 https://github.com/westonruter/webforms2 https://github.com/Modernizr/Modernizr http://www.blog ...

  5. .Net发出图片Request请求

    Stream reader = null; //可能是外部链接 if (imgUrl.ToLower().StartsWith("http://")) { var request ...

  6. 新手入门 keil MDK5 建立STM32工程

    keil uvison 是用来开发 单片机的,Keil mdk 是用来开发 ARM 的. 芯片型号是:STM32F103RB6 1,新建工程 配置属性 晶振为8M 根据实际晶振选择 生成 HEX 文件 ...

  7. Latex环境安装

    安装latex环境 sudo apt-get install texlive-full 推荐使用texstudio编辑器,简单方便高效靠谱 sudo apt-get install texstudio ...

  8. acvity和fragment通过广播联系

    今天我遇到一个问题,就是在activity中需要动态改变fragment中的控件,以前看到过可以在activity中得到fragment实例,然后修改控件: 今天实验了一个新的办法,通过新的办法,就是 ...

  9. c a header file realize of multiple .c file

    //I write a few variables declaration,then include this head-file in multiple realization-c-file,the ...

  10. 一文说尽C++赋值运算符重载函数(operator=)

    写在前面: 关于C++的赋值运算符重载函数(operator=),网络以及各种教材上都有很多介绍,但可惜的是,内容大多雷同且不全面.面对这一局面,在下在整合各种资源及融入个人理解的基础上,整理出一篇较 ...