9

In my app, I ask for permission to access SMS in Android SDK 23 (runtime permission) but the problem is dialog screen overlay showed up and access not granted .i disabled all another apps overlay but nothing changed. I found this link but not helped

and the question is how can I fix it programmatically?

seyed Jafari
  • 1,235
  • 10
  • 20
mR.Rian
  • 615
  • 2
  • 6
  • 28
  • I'm not sure if this works for you. But look into this, http://stackoverflow.com/questions/21969579/overlay-dialog-align-view – Harish Aug 29 '16 at 07:16
  • @Harish thank you but thats not my problem – mR.Rian Aug 29 '16 at 07:17
  • Thanks for your question update with link now I can able to understand your problem clearly. Yes my suggestion will not work for you. let me also look out a solution for you. – Harish Aug 29 '16 at 07:22

3 Answers3

20

Ok,

finally I found the solution, I search all the web and can't find anything useful. The answer is: When you ask for new permission don't ever do something else like showing toast or.... In my case I restart my app and ask for the next permission I use this code for restart the app.

Good luck.

Masoud Mokhtari
  • 2,390
  • 1
  • 17
  • 45
mR.Rian
  • 615
  • 2
  • 6
  • 28
  • Hi, after my tests I got the screen overlay popup only the first time I opened my app. So restarting would be a solution. But can you please explain why? – Denny Weinberg Sep 25 '16 at 16:55
  • 4
    @DennyWeinberg problem is queue of permission when you ask for your first perm there is no problem ut when you ask for second perm there is queue of perms and android count it screen overlay for permission that means you start ask for using two or more part of os – mR.Rian Oct 16 '16 at 13:58
1

Here is your solution: https://gist.github.com/Aeonitis/2337b1ca652173839395be82db7d05c3

If you have any questions, let me know.

Aeonitis
  • 5,887
  • 3
  • 14
  • 8
1

Or you can delay your code execution by using postDelayed

(new Handler()).postDelayed(new Runnable() {
   @Override
   public void run() {
      // do something
   }
}, 500); // it doesn't hurt to wait 500ms is it?
sanusi
  • 739
  • 7
  • 10