【问题标题】:Flutter permissions颤振权限
【发布时间】:2021-11-04 03:41:56
【问题描述】:

在我的应用程序中,我要求获得麦克风许可,然后通过如下方式打印来检查状态:

var micPermStatus = await Permission.microphone.request();

print(micPermStatus)

但是,有时应用程序并没有弹出请求许可的对话框,并且打印的语句显示'PermissionStatus.permanentlyDenied'

我不明白它为什么有时会这样做。我希望它每次都请求许可。

我能做些什么来解决这个问题?

谢谢。

【问题讨论】:

    标签: flutter android-permissions


    【解决方案1】:

    如果用户第一次永久拒绝权限,状态将更改为永久拒绝,您应该通过询问用户并打开应用设置来更改它来处理您的代码

    permission_handler 包是这样处理的:

    if (await Permission.microphone.isPermanentlyDenied) {
      // The user opted to never again see the permission request dialog for this
      // app. The only way to change the permission's status now is to let the
      // user manually enable it in the system settings.
      openAppSettings();
    }
    

    【讨论】:

    • 你的意思是如果用户第一次拒绝了权限,那么之后我应该提示用户打开设置并授予应用程序权限?
    猜你喜欢
    • 1970-01-01
    • 2019-06-23
    • 2022-06-28
    • 2021-08-12
    • 2021-08-18
    • 2021-03-01
    • 2020-03-13
    • 1970-01-01
    • 2021-11-17
    相关资源
    最近更新 更多