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 trialMUZ140584 Heredity Mbundire
4,979 PointsWe'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:
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);
}
});
}
}
1 Answer
Steve Hunter
57,712 PointsYou 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.
MUZ140584 Heredity Mbundire
4,979 Pointsthanks so much you a such a bright
Tate Breswick
936 PointsTate Breswick
936 PointsI 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.