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 Task 2 of 3 Let's add the same Intent flags from the video to flag this new activity as a new task and to cle

I'n not sure whats going on here I try this code on Android Studio it works like it has to be but at web site editor gives this error can anyone help with this

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

public class CodeChallengeActivity extends Activity {

    // Some code has been omitted
  Intent intent = new Intent(this, CommentActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

    public void addComment() {

    }
}
./CodeChallengeActivity.java:8: error:  expected
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                       ^
./CodeChallengeActivity.java:8: error:  expected
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                                     ^
./CodeChallengeActivity.java:9: error:  expected
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                       ^
./CodeChallengeActivity.java:9: error:  expected
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                                                       ^
./CodeChallengeActivity.java:8: error: cannot find symbol
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                              ^
  symbol:   class FLAG_ACTIVITY_NEW_TASK
  location: class Intent
./CodeChallengeActivity.java:8: error: package intent does not exist
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              ^
./CodeChallengeActivity.java:9: error: cannot find symbol
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                              ^
  symbol:   class FLAG_ACTIVITY_CLEAR_TASK
  location: class Intent
./CodeChallengeActivity.java:9: error: package intent does not exist
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
              ^
8 errors

You may want to take a look at this other forum thread for some helpful info: https://teamtreehouse.com/forum/adding-intent-flags-error

I actually had more trouble with Challenge 3 of 3:

"Challenge Task 3 of 3

Now all you need to do is start the activity!"

I kept using

"StartActivity(intent);"

...and after staring at the parse error for a while.

(gotta love those demonically-red colored cryptic parse errors),

/*
./CodeChallengeActivity.java:12: error: cannot find symbol
      StartActivity(intent);
      ^
  symbol:   method StartActivity(Intent)
  location: class CodeChallengeActivity
1 error
*/

..............

I finally realized my typing error:

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);
      startActivity(intent);
    }
}