首页 > 解决方案 > 我在没有调用 super.onResume() 的 firebase 控制台上崩溃

问题描述

我在每个活动中都调用 super.onresume,但仍然是 firebase 控制台上的崩溃报告。我有 BaseActivity,我在其中重写 onResume() 函数并从 BaseActivity 扩展每个活动。在某些活动中,我覆盖 onResume() 函数,而在某些活动中,我使用 BaseActivity onResume()

致命例外:

java.lang.RuntimeException: Unable to resume activity : android.util.SuperNotCalledException: Activity } did not call through to super.onResume()
       at android.app.ActivityThread.performResumeActivity + 3725(ActivityThread.java:3725)
       at android.app.ActivityThread.handleResumeActivity + 3775(ActivityThread.java:3775)
       at android.app.ActivityThread$H.handleMessage + 1734(ActivityThread.java:1734)
       at android.os.Handler.dispatchMessage + 110(Handler.java:110)
       at android.os.Looper.loop + 232(Looper.java:232)
       at android.app.ActivityThread.main + 6661(ActivityThread.java:6661)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1106(ZygoteInit.java:1106)
       at com.android.internal.os.ZygoteInit.main + 967(ZygoteInit.java:967)



abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {

    val BASE_EXTRA_TEXT_FOR_INTENT_INJECTION = "com.hello.world"
    val KEY_INJECTION_EXTRA_STRING = "injection_extra_string"

    var mDataBinding: T? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        try {

            mDataBinding = DataBindingUtil.setContentView(this, setLayout())


            if (intent.action != null && intent.action!!.equals(Intent.ACTION_MAIN, ignoreCase = true)) {
                return
            }
            val isSafe = intent.hasExtra(KEY_INJECTION_EXTRA_STRING)
            if (isSafe) {
                val intentInjectionStr = intent.getStringExtra(KEY_INJECTION_EXTRA_STRING)
                if (intentInjectionStr == null || !intentInjectionStr.equals(BASE_EXTRA_TEXT_FOR_INTENT_INJECTION + RootValues.getInstance().TIME_STAMP_FOR_INTENT_INJECTION)) {
                    finish()
                }
            } else {
                finish()
            }

        } catch (ex: Exception) {
        }
    }

    override fun onResume() {
        try {
            super.onResume()
            if (intent.action != null && intent.action!!.equals(Intent.ACTION_MAIN, ignoreCase = true)) {
                return
            }
            if (DeviceUtils.isDeviceRooted()) {
                finish()
            }
        } catch (ignore: Exception) {
        }
    }

    override fun onPostCreate(savedInstanceState: Bundle?) {
        try {
            super.onPostCreate(savedInstanceState)
            init(savedInstanceState)
        } catch (ignore: Exception) {
        }
    }

    abstract fun setLayout(): Int

    abstract fun init(savedInstanceState: Bundle?)


我想解决这个崩溃。这种崩溃有时会发生。

标签: javaandroidandroid-studiokotlinandroid-activity

解决方案


推荐阅读