码迷,mamicode.com
首页 > 编程语言 > 详细

java.lang.NullPointerException: Attempt to invoke virtual method 'void 、Handler.removeMessages(int)' on a null object reference

时间:2015-09-04 11:03:44      阅读:448      评论:0      收藏:0      [点我收藏+]

标签:

onDestory进行释放Handler时,需要判断null

if(null != mHandler) {
            mHandler.removeMessages(MSG_CHANGE_TEXT_COLOR);
            mHandler.removeMessages(MSG_JUMP_TO_SUCCESS_PAGE);
            mHandler.removeMessages(MSG_PLAY_LITTLE_PEOPLE_ANIMATION);
            mHandler.removeMessages(MSG_PLAY_WRONG_ANIMATION);
            mHandler.removeMessages(MSG_SPEAK_BUTTON_STATE_CHANGED);
            mHandler = null;
            DebugLog.d(TAG, "release Handler success");
}

java.lang.NullPointerException: Attempt to invoke virtual method 'void 、Handler.removeMessages(int)' on a null object reference

标签:

原文地址:http://www.cnblogs.com/ErLiangCode/p/4781366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!