Android Build an Interactive Story App Intents and Multiple Activities Putting Data in an Intent

prosper nyamukondiwa
prosper nyamukondiwa
656 Points


We've updated our LaunchActivity to include a fuel level (fuelLevel) for the spacecraft. This value needs to be passed to the FlightActivity. Add the code to pass this value along via the Intent. Use the key "FUEL_LEVEL"
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LaunchActivity extends AppCompatActivity {

    public Button launchButton;
    public int fuelLevel;

    protected void onCreate(Bundle savedInstanceState) {

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

        launchButton = (Button)findViewById(;
        launchButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Add your code in here!
                Intent intent = new Intent(LaunchActivity.this, FlightActivity.class);


1 Answer

Hey Pro; You need to add the line intent.putExtra("FUEL_LEVEL", fuelLevel); so that the value can be passed.

Happy coding!!

Jasper Allijn
Jasper Allijn
2,743 Points

I don't understand this at all. Where does the "FUEL_LEVEL" all of a sudden come from? I know the challenge told me to write that, but doesn't it need to reference something in the code for it to work? Or can I just make up words and it's all fine and dandy?

I don't think I really understand the concept of passing a value through intent yet, but the answer seems really odd to me and (with my current understanding, or lack thereof) makes more sense if it was:

intent.putExtra("fuelLevel", FlightActivity); instead of intent.putExtra("FUEL_LEVEL", fuelLevel);

So passing "fuelLevel" -> FlightActivity as explained in the challenge ("This value needs to be passed to the FlightActivity.") I've watched the video multiple times and googled it, yet I keep falling back to the same conclusion. What key point am I missing?