2012-08-08 21 views

回答

1

看起來他們clear a flag in the super methods and check that it was set

final void performStart() { 
    mCalled = false; 
    mInstrumentation.callActivityOnStart(this); 
    if (!mCalled) { 
     throw new SuperNotCalledException(
      "Activity " + mComponent.toShortString() + 
      " did not call through to super.onStart()"); 
    } 
} 
+0

我不知道這是爲什麼調用錯誤super.x方法不會導致應用程序崩潰?我不確定這是否已修正,但之前您可以在onStart中調用super.onResume,並且不會拋出異常... – ScouseChris 2012-08-08 15:03:12

+0

它很有道理;只有一個標誌。由於這是爲了防止人們忘記調用'super()',我無法想象有人會不經意地調用另一個'super()'方法。 – 2012-08-08 15:07:16