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
MUZ1407800 Doubt Milazi
11,813 PointsWhere is me going wrong from this code
now set the mFuelLevel value from the Intent.Check the Intent documantation if you need help finding the correct method to use.Use "FUEL_LEVEL" as the key and -1 as the default value.
2 Answers
David Postlethwaite
9,355 PointsmFuelLevel = getIntent().getIntExtra("FUEL_LEVEL" , -1);
adsdev
15,583 Pointsif somewhere in the code an Intent is send, you have to retrieve it by the getIntent() method.
Intent intent = getIntent();
//Values were given with the intent, to retrieve and assign them as well, as said in the task.
//It's done as followed by the documentation by assigning a key and a
//default value in the parenthesis
So...
// "A key name"
//followed by a "," followed by a default value.
//As requested with -1 */
//It should look a little like this
mFuelLevel = intent.getIntExtra("FUEL_LEVEL", -1);
Hope this helps MUZ1407800 Doubt Milazi
MUZ1407800 Doubt Milazi
11,813 Pointsthank you it helped me a lot .i rate your answer and explanation as number 1
adsdev
15,583 PointsMUZ1407800 Doubt Milazi , glad i could help ^^
MUZ1407800 Doubt Milazi
11,813 PointsMUZ1407800 Doubt Milazi
11,813 Pointsits still saying BUMPER on syntax error
David Postlethwaite
9,355 PointsDavid Postlethwaite
9,355 PointsHave you declared the an intent already i.e. Intent intent = new Intent()
if so just change it to mFuelLevel = intent.getIntExtra("FUEL_LEVEL" , -1);
MUZ1407800 Doubt Milazi
11,813 PointsMUZ1407800 Doubt Milazi
11,813 Pointsthank you it helped me a lot .only i was lacking to understand your explanation boss.