super.onCreate(savedInstanceState);不会立即调用父类的onCreate()方法。为什么?

时间:2019-04-25 07:49:50

标签: android inheritance android-activity

我从BaseClass扩展了我的所有活动。因此,我想在BaseActivity类的onCreate()中初始化公共变量。但是,super.onCreate(savedInstanceState);不会立即调用父类的onCreate()方法。为什么?

public class SplashActivity extends BaseActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     // after this line executed, next line executed rather than the onCreate() of parent BaseActivity
        ...
    }
}

public class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        ...
    }
}

0 个答案:

没有答案