Closed Kong-xyZ closed 6 years ago
你传入了什么鸡儿参数?
服务器返回的一个字符串
问题回答得准确点,具体是什么,看结果肯定是你传入了空字符串造成的,这是你自己的问题哦
嗯,应该是服务器返回的数据问题,返回的数据为null,传到你的Toast就出现这个问题了。
一般会直接把服务端返回的错误信息直接show出来,在遇到返回为null的情况下,再调用ToastUtils.showLong()方法就应用崩溃了,有什么办法规避呢?
if else 判断下不就好了么 我也可以考虑传入空显示 null
跟后端同事约定,不传入null,或者本地设置一个默认错误提示,然后判断是否为null
由于项目接入了多种外部API,所以返回协议不统一,导致无法控制返回是否为null。如果在每个返回里都去做if else或者都去给默认值的话,后面接手项目的开发者不知道有这坑的话,就麻烦了。柯基 大神有没有考虑处理下呢?
用 1.18.6 做了空处理
好的。多谢大神
main(1)
java.lang.NullPointerException Argument 'text' of type CharSequence (#0 out of 1, zero-based) is marked by @android.support.annotation.NonNull but got null for it
1 java.lang.IllegalStateException:Fatal Exception thrown on Scheduler.Worker thread.
2 rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59) 3 ...... 4 Caused by: 5 java.lang.NullPointerException:Argument 'text' of type CharSequence (#0 out of 1, zero-based) is marked by @android.support.annotation.NonNull but got null for it 6 com.blankj.utilcode.util.ToastUtils.showShort(Unknown Source)