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 trialNarain Ramjieawan
639 PointsStuck on Intent question
I am suck on this part where I have to declare an intent and get the intent that started the activity. No matter what I try I keep getting syntax errors. This is what I wrote in the editor:
I guess I am not fully understanding what is being asked of me in the question. Any help would be appreciated.
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();
String name = intent.getStringExtra("FUEL_LEVEL");
}
}
2 Answers
Seth Kroger
56,414 PointsIt's asking you to retrieve the fuel level from the intent which is an int in this case, not a String. Because it's stored as an int in the Intent, you'll need to use a different method than you would a String (getIntExtra).
Unsubscribed User
48,988 Pointsoh its getIntExtra dang... thanks for helping
Unsubscribed User
48,988 PointsUnsubscribed User
48,988 Pointsi dont get it whats wrong ?