如何使用android 11中的位置处理程序包始终在flutter中弹出设置页面链接的“位置权限”?

问题描述

我知道,在 android 11 中,寻求权限的弹出/警告对话框从不提供“始终”选项,而是提供没有它的选项,如下图所示 -

enter image description here

请注意,此弹出窗口提供了一个“设置链接”,说明您可以始终从设置中打开。

我也希望在我的 Flutter 项目中弹出这个,但我失败了!

我正在使用 permission_handler: ^8.1.1 ,如果我使用

await Permission.location.request() 它为我提供了一个弹出/警告对话框,如下图所示,但这不是我想要的。

enter image description here

我正在使用一个函数来请求始终许可,但它从不显示任何弹出窗口或对话框。

我的代码 -

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() async {
    await Permission.locationAlways.request();
    print(Permission.locationAlways.status.then((value) => print(value)));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),),body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
            Text(
              'You have pushed the button this many times:',Text(
              '$_counter',style: Theme.of(context).textTheme.headline4,],floatingActionButton: FloatingActionButton(
        onpressed: _incrementCounter,tooltip: 'Increment',child: Icon(Icons.add),// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

如何实现像第一张照片一样弹出?

AndroidMainfest.xml 场景 -

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)