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

Challenge Won't Work

What do I do here? This is the code I made for the challenge: 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);

Intent intent = getIntent(); mFuelLevel = intent.getIntExtra("FUEL_LEVEL");} } Here is the error: ./FlightActivity.java:14: error: method getIntExtra in class Intent cannot be applied to given types; mFuelLevel = intent.getIntExtra("FUEL_LEVEL");} ^ required: String,int found: String reason: actual and formal argument lists differ in length 1 error

1 Answer

Hello,

getIntExtra takes in two arguments, the first being the key for the value you want to retrieve, and the second is a default value in case there is no value to return. If you pass in the default value the challenge asks for you should be able to pass this challenge.

Thank you.

You're welcome. Good luck with Android development.