Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Activity Lifecycle The Activity Lifecycle Saving and Retrieving Instance State

I'm stuck

I'm stuck here. Can someone help me out

import android.content.Intent;
import android.view.View;

public class MainActivity extends Activity {
    public static final String KEY_USERNAME = 
  public TextView mTextView;

  protected void onCreate(Bundle savedInstanceState) {

    mTextView = (TextView) findViewById(R.id.textView);

    protected void onSaveInstanceState(Bundle outState) {


    protected void onRestoreInstanceState(Bundle savedInstanceState) {


1 Answer

There are a few issues on this line:

public static final String KEY_USERNAME = 
  • You did not give the key the right name. The instructions says: "Start by initializing a key named KEY_USERENTRY", not KEY_USERNAME
  • You need to initialise that String. Since we do not have a value yet, just give it an empty value for now (= "")
  • You forgot the semicolon at the end

Hope that helps :)