Syntax_Error
Syntax_Error

Reputation: 6220

onResume() in android runtime error

I am trying to call onResume so that I can reload variables after they are changed from another fragment after I return.

@Override
    public void onResume(){
        check1=(CheckBox)getActivity().findViewById(R.id.CheckBox01);

    }

Attached above is my onResume() code. CheckBox01 is in another fragment. However, on runtime I get an error and the application quits.

It is complaining

Unable to resume Activity: android.app.supernotcalledException: Fragment Tabmodes did not call through to super.Resume()

Where is my error?

Upvotes: 0

Views: 5320

Answers (3)

yugidroid
yugidroid

Reputation: 6690

supernotcalledException and did not call through to super.Resume() are telling what's the error!

You're missing the super.onResume(); call when overriding the onResume() method.

Upvotes: 2

Sam
Sam

Reputation: 86958

You must call the super method when you override onResume(), as the error (cryptically) states:

@Override
public void onResume(){
    super.onResume();
    check1=(CheckBox)getActivity().findViewById(R.id.CheckBox01);
}

Upvotes: 8

toadzky
toadzky

Reputation: 3846

The error is that you are required to call super.onResume. when overriding the initialize and teardown methods in android, you have to call the super version of the method or it won't work. super.onCreate, super.onResume, super.onDestroy, etc. i tend to start my init methods with the super call and end my teardown methods with it.

Upvotes: 0

Related Questions