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 Simple Android App with Java Testing and Debugging Writing to the Log

prosper nyamukondiwa
prosper nyamukondiwa
656 Points

writing the log anybody to help with a correct answer

Inside the onCreate() method (after the setContentView() call), log the message "Activity created!" using the Log debug method (remember 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.

com/teamtreehouse/TreehouseActivity.java
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 "Activitycreated", msg; TreehouseActivity;
prosper nyamukondiwa
prosper nyamukondiwa
656 Points

thanks so much , let me try answer the next question

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Prosper;

A couple of things with the above code.

  • First, your log statement should be on the line after setContentView and before the closing braces.
  • Second, double check the syntax of your Log statement. The Log.d method's signature is, in this case, Log.d(String tag, String msg).

Post back with further questions if you're still stuck.

Happy coding,
Ken

prosper nyamukondiwa
prosper nyamukondiwa
656 Points

have reached a dead end , exhausted my brain the answer is not coming through

Ken Alger
Ken Alger
Treehouse Teacher
Log.d(TAG, "Activity created!");

Is what the Log statement syntax should look like.

prosper nyamukondiwa
prosper nyamukondiwa
656 Points

HELLO ken am still facing a challenge ,can you help by puttig as it should be the whole code coz i cant figure where am getting it wrong

Ken Alger
Ken Alger
Treehouse Teacher

Prosper;

I don't want to just give you the answer outright. ;-)

Here's another hint.

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 STATEMENT GOES HERE
  }
}