//modify by hyxu 2015-9-30 to support above 19 version
public void change(boolean closeOrOpen) {
if (Build.VERSION.SDK_INT <19) {
Secure.setLocationProviderEnabled(mContext.getContentResolver(),
LocationManager.GPS_PROVIDER, closeOrOpen);
}else{
if(!closeOrOpen){
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_OFF);
}else{
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
}
}
}


public boolean isOnOff() {
if (Build.VERSION.SDK_INT <19) {
LocationManager myLocationManager = (LocationManager )mContext.getSystemService(Context.LOCATION_SERVICE);
return myLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}else{
int mode = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF);
if(mode==Settings.Secure.LOCATION_MODE_OFF){
return false;
}else{
return true;
}
}
}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android(安卓)String.xml文件中转义字符
  2. tabhost (activitygroup)中子页面弹出对
  3. android拍照显示缩略图
  4. Android(安卓)项目打包jar,生产sdk供别人
  5. [多媒体]android MediaRecoder 实现录像
  6. Android中WebViewClient与WebChromClient
  7. 日语五十音 for Android
  8. android 自定义控件继承TextView
  9. Android(安卓)MeterDesign(一)
  10. Android(安卓)Opengl 学习笔记 01——环