Android打开或者关闭GPS
来源:互联网 发布:java session工作原理 编辑:程序博客网 时间:2024/06/01 09:35
打开和关闭gps
//打开或者关闭gpspublic void openGPS(boolean open) { if (Build.VERSION.SDK_INT <19) { Secure.setLocationProviderEnabled(context.getContentResolver(), LocationManager.GPS_PROVIDER, open); }else{ if(!open){ Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_OFF); }else{ Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING); } } } //判断gps是否处于打开状态public boolean isOpen() { if (Build.VERSION.SDK_INT <19) { LocationManager myLocationManager = (LocationManager )mContext.getSystemService(Context.LOCATION_SERVICE); return myLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); }else{ int state = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF); if(state==Settings.Secure.LOCATION_MODE_OFF){ return false; }else{ return true; } } }
0 0
- Android打开或者关闭GPS
- android 打开或关闭GPS
- Android 如何打开和关闭GPS设备
- Android中如何打开或关闭GPS
- android中gps的打开关闭
- android 5.1 打开与关闭GPS
- Android判断是否连接网络或者是否打开了GPS
- Android 利用程序实现GPS的打开或关闭
- Android中如何通过程序打开或关闭GPS
- android 默认打开位置服务,默认关闭GPS设置
- Android 利用程序实现GPS的打开或关闭
- Android中如何通过程序打开或关闭GPS
- Android中如何通过程序打开或关闭GPS
- 系统中打开GPS和关闭GPS
- 打开或者关闭wifi
- [Android] 监听系统网络连接打开或者关闭的消息
- 如何在Android中获知屏幕打开或者关闭
- android 判断是否有闪光灯,打开或者关闭闪光灯
- 栈的基础知识
- npm部分常用指令
- C语言:打印杨辉三角
- AndroidVibrator(1)在lk如何启动vibrator
- TCP与UDP的区别
- Android打开或者关闭GPS
- 独立成分分析 ( ICA ) 与主成分分析 ( PCA ) 的区别
- Fragment中数据重复请求
- 数据结构算法演示
- LintCode : 用栈实现队列
- Java学习篇之自定义类的相关重写方法
- Polygon和Polyline
- 银行家算法
- Atom编辑器入门到精通(七) 编辑配置文件