android 检查GPS是否开启,GPS设置界面
16lz
2022-04-04
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) { } }
更多相关文章
- Android(安卓)自定义BaseAdapter
- android中textview设置为多行文本时,如何让文字从最顶开始显示
- android ListView的分段显示、分页显示(附源码)
- android:autoLink
- [Android]开启/关闭/监听 飞行模式
- Android标题栏各种设置
- android 自定义dialog弹出和消失缩放动画
- android上传文件至服务器
- 修改进度条ProgressBar颜色