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

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

时间: 2024-12-22 09:16:54

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

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.yunweather.app.db.YunWeatherDB.loadProvinces()' on a null object reference

NullPointerException:查看自己的什么地方是否对空指针进行了操作 Attempt to invoke virtual method 'java.util.List com.yunweather.app.db.YunWeatherDB.loadProvinces()' on a null object reference 尝试用一个空对象引用调用LoadProvinces()方法,查看调用LoadProvinces()的对象是否初始化,很可能是因为你没有初始化就调用了LoadPr

Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference

[Android]getActionBar()为null的解决方法总结 setContentView(R.layout.activity_main);android.support.v7.app.ActionBar actionBar = getSupportActionBar();actionBar.setHomeButtonEnabled(true);actionBar.setDisplayShowHomeEnabled(true);actionBar.setIcon(R.mipmap.ic

NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParam

最近在做和图片相关显示的出现了一个问题,整理一下思路,分享出来给大家参考一下: 下面是一个空指针的异常,是在GalleryAdapter中出现的. // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.Vie

Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()'

最近在做和列表或者是Gridview相关显示的出现了一个问题,整理一下思路,分享出来给大家参考一下: 其实不管是LIstView还是GridView都会可能出现,而且原因基本是一样的; // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportan

Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference xxx 的问题分析与解决方案

最近,公司要求开发一个APP,所以很苦逼的学习了几天 Android 的上手手册,但是实际运用于开发中还是捉襟见肘,困难重重:好在的是,部门还有几个专门搞安卓的大佬可以问问,哈哈 好了,进入今天的正题吧,前天开发过程中,遇到一个如“标题”所示的问题,百思不得其解!最终上网搜报错的原因,才找到问题的所在:.xml文件中运用到了不存在的标签--我的是因为粗心把<View>写成了<view>,加载的时候找不到该标签,所以页面一直运行不出来. 所以,该问题基本出在于布局页面有错(有的错误页

Attempt to write to field &#39;android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager&#39; on a null object reference

E/AndroidRuntime﹕ FATAL EXCEPTION: mainProcess: org.example.magnusluca.drawertestapp, PID: 3624java.lang.NullPointerException: Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on

spring mybatis 整合问题Error parsing Mapper XML. Cause: java.lang.NullPointerException

14:30:40,872 DEBUG SqlSessionFactoryBean:431 - Parsed configuration file: 'class path resource [mybatis/mybatis-config.xml]'14:30:40,883  WARN XmlWebApplicationContext:489 - Exception encountered during context initialization - cancelling refresh att

java.lang.NullPointerException at com.pp.controller.PPUserController.updateDetail(PPUserController.java:34)

问题原因:忘记写@Resource: 由此而知:可能是service没有引进去. 全部错误代码: 22:33:17,883 DEBUG SessionImpl:243 - Opened session at timestamp: 14308363978 22:34:11,470 ERROR AdminController:39 - 用户User [id=11, name=caowenyan, pwd=null, mail=null, photo=null, createdate=null, lo

android启动时报错Unable to instantiate application xxxx:java.lang.NullPointerException

如果程序已经运行,再安装到手机的时候总是报以下错误.而且是在打开特定的Activity的情况下才会报错. 06-26 09:45:16.971: E/AndroidRuntime(29733): java.lang.RuntimeException: Unable to instantiate application com.css.promotiontool.ui.CSSAppliction: java.lang.NullPointerException06-26 09:45:16.971: