今天在写一个程序时发生了:SuperNotCalledException异常,这个onRestart是用eclipse自动快捷生成的,结果发生了这个异常
protected void onRestart() { super.onRestart(); selectedPath=null; };
原来是An implementation of any activity lifecycle method should always first call the superclass version. For example:
protected void onRestart() {
super.onRestart();
// ...
}
当我重写了这个函数之后,要首先调用父类的onRestart因为系统在这里要进行一些处理,如果不写,那么这个函数就只会处理我添加的代码了。对于这种在框架上面的编程要时刻记住是系统来调用我们的程序,当然我们也调用系统的程序,但最终还是系统框架调用我们的程序。