Android的是如何落实SuperNotCalledException的检查? [英] How did Android implement the checks for SuperNotCalledException?

查看:450
本文介绍了Android的是如何落实SuperNotCalledException的检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

活动类,Android提供运行时执行了超()必须调用被替代的生命周期回调方法。如果你忘记了你这样做,它抛出SuperNotCalledException。

In the Activity class, Android provides runtime enforcement that super() must be called for overridden lifecycle callback methods. If you forget do do so, it throws SuperNotCalledException.

究竟怎么了这是专门落实在Android?请点我实际的代码实现,如果可能的话。

Exactly how was this implemented specifically on Android? Please point me to the actual source implementation if possible.

推荐答案

看起来他们清除标志在中超的方法,并检查它被设置

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

这篇关于Android的是如何落实SuperNotCalledException的检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆