又这样一个需求,app接受验证码,第一次进入activity的时候,toast能正常弹出,接受验证码成功之后,我退出这个activity然后再次进入,接受验证码的时候toast就不弹出,使用的是康师傅的toastutil
不显示的时候会出现这个log
2021-03-26 19:09:33.644 19375-19375/com.android.systemui W/ToastPresenter: Error while attempting to show toast from com.tangyu.simple
  android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@689d511 is not valid; is your activity running?
public class ToastUtil {
    private static Toast sToast;
    /**
     * @param msg 解决原生Toast点击多次一直显示多次的bug
     */
    @SuppressLint("ShowToast")
    public static void showToast(String msg) {
        if (sToast == null) {
            sToast = Toast.makeText(BaseActivity.getContext(), msg, Toast.LENGTH_SHORT);
        } else {
            sToast.setText(msg);
        }
        sToast.show();
    }
    @SuppressLint("ShowToast")
    public static void showToast(Context context, String msg) {
        if (sToast == null) {
            sToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        } else {
            sToast.setText(msg);
        }
        sToast.show();
    }
}
你的context使用application的呗!