getActivity / Toaster

Android 吐司框架,专治 Toast 各种疑难杂症
Apache License 2.0
3.25k stars 406 forks source link

ToastUtils.java line 304 com.hjq.toast.ToastUtils.isDebugMode #101

Closed billdizl closed 1 year ago

billdizl commented 1 year ago

【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】

问题描述

请回答

其他

at android.view.KeyEvent.dispatch(KeyEvent.java:2713) at android.app.Activity.dispatchKeyEvent(Activity.java:3373) at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122) at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84) at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140) at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:599) at com.chiquedoll.chiquedoll.view.activity.BaseActivity.dispatchKeyEvent(BaseActivity.java:841) at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59) at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:3089) at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:381) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5082) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4950) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4471) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4524) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4490) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4630) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4498) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4687) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4471) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4524) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4490) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4498) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4471) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4524) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4490) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4663) at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4824) at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2571) at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2081) at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2072) at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2548) at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:326) at android.os.Looper.loop(Looper.java:160) at android.app.ActivityThread.main(ActivityThread.java:6923) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

getActivity commented 1 year ago

小伙子,出现这种情况可能的原因有两个:

  1. 你没有调用 ToastUtils.init 就调用了 ToastUtils.show
  2. 你没有在 Application.onCreate 方法中调用 ToastUtils.init,又或者你采用了延迟初始化框架