File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
library/src/main/java/com/hjq/toast Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -191,11 +191,13 @@ public void run() {
191191 setShow (true );
192192 // 发送无障碍事件
193193 sendAccessibilityEvent (mToast .getView ());
194- } catch (IllegalStateException | WindowManager . BadTokenException e ) {
195- // 如果这个 View 对象被重复添加到 WindowManager 则会抛出异常
194+ } catch (Exception e ) {
195+ // 1. 如果这个 View 对象被重复添加到 WindowManager 则会抛出异常
196196 // java.lang.IllegalStateException: View android.widget.TextView has already been added to the window manager.
197- // 如果 WindowManager 绑定的 Activity 已经销毁,则会抛出异常
197+ // 2. 如果 WindowManager 绑定的 Activity 已经销毁,则会抛出异常
198198 // android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@ef1ccb6 is not valid; is your activity running?
199+ /// 3. 厂商的问题也会导致异常的出现,Github issue 地址:https://github.com/getActivity/Toaster/issues/149
200+ // java.lang.RuntimeException: InputChannel is not initialized.
199201 e .printStackTrace ();
200202 }
201203 }
@@ -214,8 +216,8 @@ public void run() {
214216
215217 windowManager .removeViewImmediate (mToast .getView ());
216218
217- } catch (IllegalArgumentException e ) {
218- // 如果当前 WindowManager 没有附加这个 View 则会抛出异常
219+ } catch (Exception e ) {
220+ // 如果当前 WindowManager 没有添加这个 View 则会抛出异常
219221 // java.lang.IllegalArgumentException: View=android.widget.TextView not attached to window manager
220222 e .printStackTrace ();
221223 } finally {
You can’t perform that action at this time.
0 commit comments