首页 > 解决方案 > Android N, O App Overlay stays after Permission request declined

问题描述

I have an app that needs access to the users accounts.
As the user declines the Contact Permission Dialog, the odd behaviour begins.

As usual the dialog appears and the app in background gets an overlay to darken content. If the user declines the permission now, the dialog disappears, but the darkening overlay stays (it also prohibits user-interaction).
The content visible behind overlay is changed accordingly to the declined permission. The Error occurs only on devices with Android N and Android O, M looks perfectly after declining and lower api levels do not have runtime permissions, so they are doing their job as well.

A few stats:

Also there are other permission requests, which are working just as they should (e.g. Location).
Only the dialog shown for GET_ACCOUNTS (Contact permission Group) does not handle the overlay right.

It would be awesome, if somebody could give me some hints, which dependencies may exist that I did not see.
Thanks a lot in advance to everybody reading this, giving my problem a few thoughts, sharing a similar story even without a solution. Every hint or input will be appreciated :D

Update:

I removed the permission dialog and present the accountChooser to the user, but the misbehaviour stays. The only difference is, that even after choosing an account (and so granting the permission for this account) the overlay stays. As in background the app is visible, I can verify the features functionality and online data is available.

标签: androidandroid-permissionsandroid-8.0-oreoandroid-7.0-nougat

解决方案


经过长时间的搜索,权限对话框或帐户选择器似乎不是问题,而是通过按下按钮激活的底层progressDialog问题。现已弃用的 progressDialog 已启动,背景为灰色且不活动。现在两个正式可疑的对话开始了。在他们确认后,他们被正确隐藏了。不活动的灰色覆盖是旧进度对话框的一部分。我确信该错误是由于时间问题造成的,同时隐藏了被两个系统对话框打断的 progressDialog。

我的解决方案是废弃旧的 progressDialog 并构建一个替换(自定义警报对话框),它在单独的线程中显示和取消。自定义对话框现在按原样隐藏,甚至灰色覆盖也正确消失。

谢谢大家,我希望这可以帮助其他人更快地找到他们的解决方案;)


推荐阅读