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 a Self-Destructing Message Android App Starting the App Navigation with Back and Up

Boyan Angelov
Boyan Angelov
26,485 Points

Adding intent flags error

I get a syntax error. Here's my code, hope somebody can show me what I'm doing wrong :)

import android.app.Activity;
import android.content.Intent;

public class CodeChallengeActivity extends Activity {

    // Some code has been omitted

    public void addComment() {
      Intent intent = new Intent(this, CommentActivity.class);
      intent.addFlags(Intent.FlAG_ACTIVITY_NEW_TASK);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    }
}

2 Answers

Jonathan Baker
Jonathan Baker
2,304 Points

There are two potential issues here that I am seeing.

a) It looks like your first flag has a non-captialized "L". Should be Intent.FLAG_ACTIVITY_NEW_TASK

b) The second flag you are using is only available on Honeycomb or newer. If your minSdkVersion is set to something lower than 11, you may get a warning about using that flag.

Other than that, it looks fine to me.

Boyan Angelov
Boyan Angelov
26,485 Points

Thanks a lot Jonathan! It was the typo :)

Jonathan Baker
Jonathan Baker
2,304 Points

Glad it was something so simple. Trust me, I've done the same thing many times. =)