how to fix screen overlay detected programmatically

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 16:01:05

问题


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?


回答1:


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.




回答2:


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

If you have any questions, let me know.




回答3:


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?


来源:https://stackoverflow.com/questions/39200416/how-to-fix-screen-overlay-detected-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!