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 trialSavitha Narayana
1,799 PointsHow to get the Intent?
I am gettint compile error
import android.os.Bundle;
import android.content.Intent;
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 data = intent.getStringExtra("FUEL_LEVEL");
}
}
3 Answers
Kristian Terziev
28,449 PointsIf I get this right, you're are stuck at step one of the challenge. The task is written a bit confusing, but you are required to just declare that intent variable. Nothing else. Meaning the only line of code you need, in order to complete task 1, is:
Intent intent = getIntent();
EDIT: I notice you're trying to use getStringExtra. You are about to encounter another problem in task two. Make sure you pay attention to what type of variable you're using throughout the challenges. In the videos, you do the examples with String. What about the challenges? Is getStringExtra the method you need here?
Savitha Narayana
1,799 PointsThank you Kristian , i figured out :)
Kristian Terziev
28,449 PointsWould you mind marking the thread as "solved" so others can find help if needed?
Kristian Terziev
28,449 PointsNot what I ment. You have to select "Best Answer" and the thread will be marked.
Harry James
14,780 PointsHarry James
14,780 PointsMarking as Best Answer - Asker has regarded this as solved