简体   繁体   English

使用 flutter 定位插件在 Android 中自动添加后台定位权限

[英]Background location permission auto-added in Android with flutter location plugin

I recently added the Flutter location plugin to allow my app to use GPS.我最近添加了 Flutter位置插件,以允许我的应用程序使用 GPS。 Everything is working as expected on iOS and App Store, but when building for Android (targetSdkVersion 29 / API level 29) and uploading to Google Play it tells me that the background location permission is present. iOS 和 App Store 上的一切都按预期工作,但是在为 Android 构建时(targetSdkVersion 29 / API 级别 29)并上传到后台权限告诉我谷歌播放它I can verify that by looking in the build where the我可以通过查看构建

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

line is added to the AndroidManifest.xml file.行被添加到 AndroidManifest.xml 文件中。

However, my app doesn't use location in the background, and I just can't find out how I remove this permission that is being automatically added by the location plugin.但是,我的应用程序没有在后台使用位置,我只是不知道如何删除位置插件自动添加的这个权限。

The only code that uses location plugin is this line I have in a method:使用位置插件的唯一代码是我在方法中的这一行:

LocationData userLocation = await new Location().getLocation();

The permission is introduced by the location plugin.权限由位置插件引入。 If you go to its manifest you'll find the following requested permissions:如果你 go 到它的清单,你会发现以下请求的权限:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

To remove it add要删除它添加

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
                     tools:node="remove"/>

to your apps Manifest.到您的应用清单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM