android 检查GPS是否开启,打开GPS设置界面
16lz
2021-01-23
转自http://iriverman.iteye.com/blog/807965
GPS是否开启LocationManager locationManager = (LocationManager)getContext().getSystemService(Context.LOCATION_SERVICE);return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);进入GPS设置页面 Intent intent = new Intent(); intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { getContext().startActivity(intent); } catch(ActivityNotFoundException ex) { // The Android SDK doc says that the location settings activity // may not be found. In that case show the general settings. // General settings activity intent.setAction(Settings.ACTION_SETTINGS); try { getContext().startActivity(intent); } catch (Exception e) { } }
更多相关文章
- Fragment切换页面
- Android进入页面开始就自动弹出软键盘
- Android引导页面的实现
- Android原生页面(练手任务)
- Android setting各子页面地址
- H5页面调用android方法传json格式
- android实现页面背景的左右移动