Methond 1 is to check whether the GPS is on:

1
2
3
4
5
public boolean isGPSIsOn() {
LocationManager locationManager = (LocationManager) mContext
.getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}

Method 2 is to open GPS setting page in Android device:

1
2
3
4
5
6
7
8
9
public void openGPSSettingPage() {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
}
}

Codes in Github : https://gist.github.com/Viyu/9406327

2 GPS utility methods的更多相关文章

  1. [翻译]NUnit---Exception && Utility Methods (六)

    网址:http://www.cnblogs.com/kim01/archive/2013/04/01/2994378.html Exception Asserts (NUnit 2.5) Assert ...

  2. Effective Java 27 Favor generic methods

    Static utility methods are particularly good candidates for generification. The type parameter list, ...

  3. Vue中computed,methods 和watch

    Vue中的计算属性和方法属性 1.计算属性 computed 模版中可以使用表达式 <div id="example"> {{ message.split('').re ...

  4. 009 The Interfaces In JAVA(官网文档翻译)

    Interfaces There are a number of situations in software engineering when it is important for dispara ...

  5. iOS 第三方库、插件、知名博客总结

    iOS 第三方库.插件.知名博客总结 用到的组件 1.通过CocoaPods安装 项目名称 项目信息 AFNetworking 网络请求组件 FMDB 本地数据库组件 SDWebImage 多个缩略图 ...

  6. [转载]Java 8 日期&时间 API

    Java 8 日期和时间 声明 本文转自http://www.journaldev.com/2800/java-8-date-localdate-localdatetime-instant,以mark ...

  7. Android AppBar

    AppBar官方文档摘记 2016-6-12 本文摘自Android官方文档,为方便自己及其他开发者朋友阅读. 章节目录为"Develop > Training > Best P ...

  8. 2000条你应知的WPF小姿势 基础篇<15-21>

    在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师,对C#和WPF有着极深的热情.最为出色的是他维护了两个博客:2,000Things You Should Know ...

  9. Java资源大全中文版(Awesome最新版)

    Awesome系列的Java资源整理.awesome-java 就是akullpp发起维护的Java资源列表,内容包括:构建工具.数据库.框架.模板.安全.代码分析.日志.第三方库.书籍.Java 站 ...

随机推荐

  1. tomcat的下载安装和配置以及和eclipse的配置

    一.Tomcat的下载安装环境变量配置 下载Tomcat 可以安装Tomcat了.下载好压缩包后,直接解压至某一目录下,目录中不能包含中文,上面安装JDK的时候也是.解压后如下所示: 将此文件夹拷贝到 ...

  2. Interesting things in Unity 4.5 you probably didn't know about

    http://va.lent.in/interesting-things-in-unity-4-5-you-probably-didnt-know-about/

  3. 图片延迟加载jquery插件imgLazyLoad(三)

    此Jquery插件是在图片加载前显示一个加载图片,当图片下载完毕后显示图片出来,可对图片进行是否自动缩放功能,此Jquery插件使用时可让页面先加载,而图片后加载的方式,解决了平时使用时要在图片显示出 ...

  4. fastjson是阿里巴巴的开源JSON解析库

    fastjson的API十分简洁. String text = JSON.toJSONString(obj); //序列化 VO vo = JSON.parseObject("{...}&q ...

  5. 【Delphi】获取EIP

    var EIP: Cardinal; procedure GetEIP(); stdcall; asm pop eax; mov EIP,eax; push eax; end; procedure T ...

  6. CSV文件的读取 导出

    CSV文件是 逗号分隔值文件 内容基本是这么存的... 姓名,年龄,性别/r/n王有才,,男/r/n王二妞,,女 一行值内用逗号 , 分开  行与行之间用  /r/n  分隔 说白了,他其实是一个字符 ...

  7. Sqlserver2008 表分区教程

    先声明..Sql2008只有企业版才能够搞这个表分区.其他版本请自觉更改.. 哥在这里费了很长时间劲..结果还是老老实实的重装.. 表分区定义 一般情况下,我们建立数据库表时,表数据都存放在一个文件里 ...

  8. YII2操作mongodb笔记(转)

    componets配置: 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://test: ...

  9. 新浪微博客户端(40)-使用AFN发送带图片的微博

    DJComposeViewController.m /** 发微博 */ - (void)sendStatusRequest { AFHTTPSessionManager *RequestManage ...

  10. strtol,strtoll,strtoul, strtoull字符串转化成数字

      今天看kafka,有一个参数选项中有: 'S'   seq=strtoull(optarg,NULL,10); do_seq=1; 之后查找了下 strtoull 函数的功能,了解如下: ---- ...