问题1:
Can't create handler inside thread that has not called Looper.prepare()
解决1:
Looper.prepare();
问题2:
getMainLooper()' on a null object reference
解决2:
Looper.getMainLooper()
问题3:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
解决3:
对这种情况一定要先判断是否为空,如果不为空再做强转
Integer tmp;...if(tmp) != null) { setValue(tmp.intValue()); }
问题4:Actually, there were zero interactions with this mock.
本文针对Android开发中常见的NullPointerException问题提供了解决方案,包括如何正确使用Looper.prepare()和getMainLooper(),以及如何避免对空对象引用进行方法调用。同时介绍了在使用Mock对象时可能出现的问题。
232

被折叠的 条评论
为什么被折叠?



