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

Viewed 426

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.

1 Answers

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();
    }
}
Related