简体   繁体   中英

Unable to resume activity SuperNotCalledException. Activity did not call through to super.onResume()

I am working on an existing code base. I am trying to ad a deeplink to an Activity . However when I test the deeplink it goes to the Activity then the Fragment is loaded but then force closes with the following error. When I debug it goes up to the point where the rest call is enqueued but before the response the Activity closes.

java.lang.RuntimeException: Unable to resume activity {com.detail.Activity}: android.util.SuperNotCalledException: Activity {com.detail.Activity} did not call through to super.onResume()

However, I do have the override onResume method where super.onResume() is being called in both the Activity and the Fragment that it loads.

@Override
public void onResume() {
    try {
        if (settingsMain.getAnalyticsShow() && !settingsMain.getAnalyticsId().equals(""))
             AnalyticsTrackers.getInstance().trackScreenView("Rating");
        super.onResume();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

So not sure what is causing it and I am new to Android development. Any assistance appreciated.

It isn't called because AnalyticsTrackers.getInstance().trackScreenView("Rating") throws an exception and the code jumps to the catch block resulting in the SuperNotCalledException .

It should be

@Override
public void onResume() {
    super.onResume();

    try {
        if (settingsMain.getAnalyticsShow() && !settingsMain.getAnalyticsId().equals(""))
            AnalyticsTrackers.getInstance().trackScreenView("Rating");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM