我正在尝试使用插件 location 获取设备的当前位置但 Android 从不要求权限。我收到此错误:
Exception has occurred. PlatformException (PlatformException(PERMISSION_DENIED_NEVER_ASK, Location permission denied forever- please open app settings, null))
我在我能在 Android 文件夹中找到的每个“AndroidManifest.xml”文件中添加了下面这行(实际上我不知道应该使用哪一个,我找到了其中的 3 个)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
我试过插件 permission_handler手动请求它们,但仍然没有弹出窗口。
我完全迷路了,我在网上找不到任何类似的东西。这是代码:
Future<LocationData> _getLocation() async {
LocationData currentLocation;
// returns a map with unreadable numbers which make no sense
var t = await PermissionHandler()
.requestPermissions([PermissionGroup.location]);
// returns false
var test = await location.requestPermission();
try {
currentLocation = await location.getLocation();
} catch (e) {
currentLocation = null;
}
return currentLocation;
}
编辑:我在我的设备 (OnePlus 6) 和模拟器 (Pixel XL API 28) 上试过这个。我也尝试过卸载/重新安装该应用程序。
最佳答案
关于android - Flutter - Android 不请求权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55659267/