致使出现Force Close的缘由有不少,常见的有好比空指针啦,类没有找到啦,资源没找到,就连Android API使用的顺序错误也可能致使(好比setContentView()以前进行了findViewById()操做)html
Force Close有的人说能够用来让应用彻底退出 而故意致使这个问题,让程序强制关闭,这种作法我仍是不经常使用。java
如何避免弹出Force Close窗口 能够实现Thread.UncaughtExceptionHandler接口的uncaughtException方法 代码以下:android
java.lang.Thread.UncaughtExceptionHandler; android.app.Application; MyApplication Application UncaughtExceptionHandler { @Override onCreate() { .onCreate(); } @Override uncaughtException(Thread thread, Throwable ex) { thread.setDefaultUncaughtExceptionHandler( ); } }
再补充一句,想要哪一个线程能够处理未捕获异常,thread.setDefaultUncaughtExceptionHandler( this); 这句代码都要在那个线程中执行一次app