Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Confused about savedInstanceState...

I'm confused about the meaning of (Bundle savedInstanceState) in this context (on the third line):

public class AlertDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Context context = getActivity();
        AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setTitle(R.string.error_title)
                .setMessage(R.string.error_message)
                .setPositiveButton(R.string.error_ok_button_text, null);
        AlertDialog dialog = builder.create();
        return dialog;
    }
}

I tried looking it up but didn't find a good answer. Can someone who understands please dumb it down a little bit for me? Thanks!

Ben Deitch
Ben Deitch
Treehouse Teacher

Watching the first two videos from this course might help.

1 Answer

Hello Jake,

It's important to pay attention to annotations(@Override), if you're extending some class it may tell you that you MUST override some method that will be called by some thread at some moment(almost always events from user or operating system)

savedInstanceState is an object of type Bundle that is passed as argument when this method is called