Rob*_*ste 6 permissions android flutter
我正在尝试使用插件位置获取设备的当前位置,但 Android 从不要求权限。我收到此错误:
发生异常。平台异常(平台异常(PERMISSION_DENIED_NEVER_ASK,位置权限永远被拒绝 - 请打开应用设置,空))
我在 Android 文件夹中可以找到的每个“AndroidManifest.xml”文件中都添加了以下行(不知道我实际上应该使用哪一个,我找到了其中的 3 个)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)
我尝试使用插件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;
}
Run Code Online (Sandbox Code Playgroud)
编辑:我在我的设备(OnePlus 6)和模拟器(Pixel XL API 28)上试过这个。我也尝试卸载/重新安装该应用程序。
在询问location 插件的 git 之后,我这样做了:
flutter clean
Run Code Online (Sandbox Code Playgroud)
我得到了要求权限的弹出窗口。
感谢这家伙。
| 归档时间: |
|
| 查看次数: |
13055 次 |
| 最近记录: |