[英]Android 6 Marshmallow Black Screen after set Permission to Never Ask Again
I have got this really weird behaviour. 我有这种非常奇怪的行为。
After adding the permissions at runtime for my app, I was checking and testing all cases. 在运行时为我的应用添加权限之后,我正在检查和测试所有情况。
I have the request code in my MainActivity. 我的MainActivity中有请求代码。
So, after I set Never Ask Again and deny the giving permission for ACCESS_FINE_LOCATION, if I press the menu button and then restart the app (the app will call onResume of MainActivity I guess), then the screen is black except a rectangle part in the middle of the screen which varies in size. 因此,在设置“不再询问”并拒绝授予ACCESS_FINE_LOCATION的许可后,如果我按菜单按钮然后重新启动应用程序(我猜该应用程序将调用MainActivity的onResume),则屏幕为黑色,除了屏幕中间大小不一。 (Is not the AlertDialog size) (不是AlertDialog的大小)
Here some screenshots: 这里有一些截图:
Normal screen 正常画面
After press menu and then open again can be that it opens with the normal state or with these states: 在按下菜单然后再次打开后,可以以正常状态或以下状态打开它:
Or 要么
This is quite weird, anybody had this before? 这很奇怪,有人以前有过吗?
Thanks for your answers! 感谢您的回答!
Without seeing the code, it's hard to give a very accurate answer. 如果不看代码,很难给出一个非常准确的答案。
When requesting permissions, if the user selected 'never ask again', the request permissions response will be denied. 请求权限时,如果用户选择“不再询问”,则请求权限响应将被拒绝。 I'm GUESSING (due to lack of code) that your app relies on the granted permission to continue loading the UI and executing more code, which it won't do if permission is denied. 我正在猜测(由于缺少代码),您的应用程序依赖于授予的权限才能继续加载UI和执行更多代码,如果权限被拒绝,则不会这样做。 You need to handle all possible responses when requesting runtime permissions. 请求运行时权限时,您需要处理所有可能的响应。
if permission is granted: good to go if permission is denied: check if you should show the permission rationale. 如果已授予许可:如果拒绝许可,则可以执行:检查是否应显示许可理由。 This means you display a message to the user explaining why you need the permission. 这意味着您向用户显示一条消息,解释为什么需要许可。
if shouldShowRationale is true: it means 'never ask again' was NOT checked. 如果shouldShowRationale为true:表示未选中“不再询问”。 Display the message, then ask for permission again. 显示消息,然后再次请求权限。
if should show Rationale is false: it means 'never ask again' was checked and you should probably direct the user to the app settings to turn the permission on if it's required. 如果应该显示Rationale为假:表示选中了“不再询问”,您可能应该将用户引导至应用设置以打开权限(如果需要)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.