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

1 Answer

Maxwell Newberry
Maxwell Newberry
Front End Web Development Techdegree Student 7,675 Points

You learn to do this in Sending Data to New Activity. The key is in the name of the challenge, Putting Data in an Intent. On line 24, we declare the intent variable and address our two parameters. The next thing we need to do is "put" our data, or fuel level, to FlightActivity. We can accomplish this using the putExtra() function where our two parameters, if you remember from the lesson, are (key, value). So, if we wanted to pass data, ensure we are on a line below the intent declaration and put the following line:

intent.putExtra("FUEL_LEVEL", fuelLevel);