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 Build an Interactive Story App (Retired) Intents and Multiple Activities Putting Data in an Intent

We've updated our LaunchActivity to include a fuel level (mFuelLevel) for the spacecraft. This value needs to be passed

I don't know what is wrong wth this:

LaunchActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LaunchActivity extends Activity {

  public Button mLaunchButton;
  public int mFuelLevel;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launch);

    // mFuelLevel is set elsewhere.
    // Code ommitted for brevity!

    mLaunchButton = (Button)findViewById(R.id.launchButton);
    mLaunchButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        // Add your code in here!
        Intent intent = new Intent(LaunchActivity.this, FlightActivity.class);
        Intent.putExtra("FUEL_LEVEL",mFuelLevel);  // use a lower case i at the beginning!
        startActivity(intent);
      }
    });
  }
}
Tate Breswick
Tate Breswick
936 Points

I had an issue on this very same task and realized after reading this how to solve it.

The prompt for this problem tells you to put your code in ABOVE the Intent... see above "//Add your code here!" Don't add it there or it won't work. you have to add it BELOW like this example has.

1 Answer

You need to use the variable called intent that you just created, not the class Intent that you are currently using. So change the capital I to a lower case one in your code; I've marked it with a comment.

Steve.

thanks so much you a such a bright