www.itboth.com/d/qIVZju/an…

Toast – WindowManager. addView–>>badToken – this issue is likely to occur on 7.1.1 models due to targetSDKVersion being raised to 26. The stable recurrence step is that after toast.show (), the UI Thread does something time-consuming to block Handler message processing, such as using Thread.sleep(5000), and the crash occurs. If the UI is not executed within this period, the handler message inside toast.show () will not be executed. If the UI is not executed within this period, the handler message inside toast.show () will not be executed. NotificationManageService that will end the Toast cancelled, at the same time the Toast for window token is invalid. When the App actually needs to display Toast, ViewRootImpl throws the above exception because the Window Token is no longer valid. In Android 8.0, Google realized this bug and added try-catch protection inside Toast. At present, only the Toast in 7.1.1 has this problem. The crash is in the system source code, and the App layer is also difficult to deal with. There are other good solutions, welcome to discuss