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. 用arp-scan扫描局域网IP地址

    1,在安装之前需要安装yum install -y libpcap libpcap-devel如果没有安装yum工具需要用rpm安装如下软件包[root@oradba arp-scan-1.8]# y ...

  2. JavaWeb学习笔记——javabean

  3. Java数据库——PreparedStatement接口

    PreparedStatement接口是Statement的子接口,属于预处理操作,与直接使用Statement不同的是,PreparedStatement在操作时,是先在数据表中准备好了一条SQL语 ...

  4. 使用kvm虚拟出Centos6.5系统相关步骤

    使用kvm虚拟出Centos6.5系统相关步骤 kvm是啥东西,亲们自行百度哇,一两句话也说不清楚,直接进主题使用宿主机虚拟出一台centos6.5的系统,当然其他系统也可以的,考虑到企业常用服务器系 ...

  5. hasClass addClass removeClass

    //函数有class function hasClass(ele,cls){ return -1<(" "+ele.className+" ").inde ...

  6. Unity3D热更全书

    http://www.cnblogs.com/crazylights/p/3897742.html

  7. Android studio 的初始设置

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

  8. fibonacci 数列及其应用

    fibonacci 数列及其延展 fibonacci计算 fibonacci数列是指 0,1,1,2,3,5,8,13,21……这样自然数序列,即从第3项开始满足f(n)=f(n-1)+f(n-2): ...

  9. 负margin小记

    static元素  margin-top/left负值,元素向指定方向移动,               margin-bottom/right负值,元素不动,后续元素前移 float元素   左浮, ...

  10. nginx 日志切割

    #!/usr/bin/python #-*-coding:UTF-8-*- import time import os logdir='/data/log/nginx' nginxpath='XX/l ...