Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Testing and Debugging

Inside the onCreate() method (after the setContentView() call), log the message "Activity created!" using the Log debug method (remember that it's just one letter). The 1st parameter should be "TreehouseActivity", but use the TAG variable instead of typing it out a second time. The 2nd parameter is the message.

The Code:

package com.teamtreehouse;

public class TreehouseActivity extends Activity {

public static final String TAG = "TreehouseActivity";

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_treehouse);

} }

I dont understand this

2 Answers

Daniel Hartin
Daniel Hartin
18,106 Points

Okay so on the line after setContentView(R.layout.activity_treehouse); You want to type the following Log.d(TAG, "Activity Created!");

This line is a method call where we are passing in parameters for the method to use. Log is the class, d is the method, the use of parentheses () mean a method call.

The method in this instance takes 2 parameters the TAG variable which has been defined for you earlier in the code, and then the message which the challenge states yo should use "Activity Created!".

Hope this helps Daniel

package com.teamtreehouse;

public class TreehouseActivity extends Activity {

    public static final String TAG = "TreehouseActivity";

    @Override public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_treehouse);
        Log.d(TAG, "Activity Created!");
    } 
}

Thanks For helping Juan!

Thanks For helping Juan!