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 Getting Data from an Intent

Now set mFuelLevel the the value from the Intent. Check the Intent documentation if you need help finding the correct me

help

FlightActivity.java
import android.os.Bundle;

public class FlightActivity extends Activity {

  public int mFuelLevel = 0;

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

    // Add your code below!
   mFuelLevel = intent.getIntExtra("FUEL_LEVEL", -1);
    Intent intent = getIntent();
    intent.putExtra("FUEL_LEVEL", mFuelLevel);
    startActivity (intent);
  }
}

3 Answers

Hello,

This task is asking that you get the value from the intent. So you don't need to be putting any extras onto the intent or starting any activity for this task so you can remove those two lines. Once you've done that, you just need to make sure you're trying to get the data from the intent after you've gotten the intent so you would want the line "mFuelLevel = intent.getIntExtra("FUEL_LEVEL", -1);" to come after the line "Intent intent = getIntent();" Please lete me know if you need any further help and please provide what your updated code looks like so we can assist you from where you are at.

import android.os.Bundle;

public class FlightActivity extends Activity {

public int mFuelLevel = 0;

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

// Add your code below!
Intent intent = getIntent();
mFuelLevel = intent.getIntExtra("FUEL_LEVEL", -1);

} }

Are you still having issues? It looks like your code should work. I'm sorry if I was a bit unclear about updating the code, I meant that you should repost if you were still having issues.

Not at all thanks the code passed thanx a lot man .GOD BLESS U cheers