当前位置:网站首页 > 编程语言 > 正文

定位打开了无法获取位置安卓手机(安卓手机获取定位失败)



static Future<FlutterLocation> determinePosition() async { bool serviceEnabled; LocationPermission permission; Position p; try {
    //这里使用的权限申请插件 ,请自行搜索相关文档配置获取依赖 PermissionStatus permissionStatus
= await LocationPermissions().requestPermissions(); if(PermissionStatus.granted == permissionStatus) { // Test if location services are enabled. serviceEnabled = await Geolocator.isLocationServiceEnabled(); if (!serviceEnabled) { // Location services are not enabled don't continue // accessing the position and request users of the // App to enable the location services. return Future.error('Location services are disabled.'); } permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); if (permission == LocationPermission.deniedForever) { // Permissions are denied forever, handle appropriately. return Future.error( 'Location permissions are permanently denied, we cannot request permissions.'); } if (permission == LocationPermission.denied) { // Permissions are denied, next time you could try // requesting permissions again (this is also where // Android's shouldShowRequestPermissionRationale // returned true. According to Android guidelines // your App should show an explanatory UI now. return Future.error('Location permissions are denied'); } } // p = await AMapLocationClient.getLocation(true); p = await Geolocator.getCurrentPosition(); print('location is get ${p}'); } else{ await LocationPermissions().openAppSettings(); } } catch (e) { ToastUtil.showToast('获取定位失败:$e'); } return FlutterLocation(p?.latitude, p?.longitude); }
到此这篇定位打开了无法获取位置安卓手机(安卓手机获取定位失败)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • samba设置共享文件夹(windows如何设置samba共享怎么用)2024-12-09 12:27:05
  • 字体图标不显示(桌面字体不显示)2024-12-09 12:27:05
  • bv衣服是什么品牌(bxv服饰是什么牌子)2024-12-09 12:27:05
  • 网址ip查询域名解析(网址ip查询域名解析失败)2024-12-09 12:27:05
  • e71409故障码(e7故障代码)2024-12-09 12:27:05
  • 匿名聊天网页(匿名聊天网页版缘起)2024-12-09 12:27:05
  • awnv是什么意思(awn是什么意思?)2024-12-09 12:27:05
  • 卡巴斯基离线更新(卡巴斯基免费版离线激活)2024-12-09 12:27:05
  • 104规约遥信报文解析(104规约遥测报文解析)2024-12-09 12:27:05
  • m301h打开ADB口令(m301h如何打开adb)2024-12-09 12:27:05
  • 全屏图片