摇动“始终允许位置"在Android上 [英] Flutter "Always allow location" on Android

查看:40
本文介绍了摇动“始终允许位置"在Android上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要跟踪骑手,那里需要跟踪他们在后台的位置.允许位置的弹出消息存在问题:只有 3个选项

I need to track riders and there for need to track their location in the background. There is an issue with a pop up message for allowing location: there are only 3 options

我希望始终允许"该弹出窗口中的选项

I'd like to have "Always allow" option in this pop up

我该如何在Android上做到这一点?

How can I do it for Android?

推荐答案

在Android 10(API级别29)及更高版本上,您必须在应用的清单中声明ACCESS_BACKGROUND_LOCATION权限,以便在运行时请求后台位置访问.在早期版本的Android上,当您的应用接收前台位置访问权限时,它也会自动接收后台位置访问权限.

On Android 10 (API level 29) and higher, you must declare the ACCESS_BACKGROUND_LOCATION permission in your app's manifest in order to request background location access at runtime. On earlier versions of Android, when your app receives foreground location access, it automatically receives background location access as well.

当应用程序中的功能请求运行Android 10(API级别29)的设备上的后台位置时,系统权限对话框将包含一个名为Always的选项.如果用户选择此选项,则您应用中的功能会获得后台位置访问权限.

When a feature in your app requests background location on a device that runs Android 10 (API level 29), the system permissions dialog includes an option named Allow all the time. If the user selects this option, the feature in your app gains background location access.

但是,在Android 11(API级别30)及更高版本上,系统对话框不包含允许所有时间"选项.相反,用户必须在设置页面上启用后台位置.

On Android 11 (API level 30) and higher, however, the system dialog doesn't include the Allow all the time option. Instead, users must enable background location on a settings page.

font: https://developer.android.com/training/location/permissions

这篇关于摇动“始终允许位置"在Android上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆