简体   繁体   中英

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.

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. (Is not the AlertDialog size)

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM