mR.Rian
mR.Rian

Reputation: 645

how to fix screen overlay detected programmatically

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?

Upvotes: 9

Views: 14695

Answers (3)

mR.Rian
mR.Rian

Reputation: 645

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.

Upvotes: 20

sanusi
sanusi

Reputation: 769

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?

Upvotes: 1

Aeonitis
Aeonitis

Reputation: 5897

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

If you have any questions, let me know.

Upvotes: 1

Related Questions